The Spanish authorities have published a list of hotels and short-stay accommodation that will remain open during the state of emergency. You can find the list at the end of this document: https://www.boe.es/…/di…/2020/03/25/pdfs/BOE-A-2020-4027.pdf.
Whilst these are mainly intended for workers, they will also be available for tourists who have been unable to return home.
British Ambassador Hugh Elliott said: “This is a very difficult time for British nationals who find themselves currently unable to get back to the UK and we welcome this announcement by the Spanish authorities that some hotels and short-stay accommodation will remain open during the state of emergency.
Such accommodation is mainly aimed at workers, but there will be options available for British travellers who have not been able to return to the UK yet.
Meanwhile we are in close contact with airlines to ensure those of you who wish to return home are able to do so in the coming days.
More generally, if you live in the UK and are currently travelling in Spain, you should be making plans to return to the UK while there are still commercial routes available.