For people living in Spain with Spanish public health care provided by an S1 form they should apply for the New EHIC card and not the GHIC which is for UK residents only. You can only apply for this if you were legally resident in Spain (i.e. had a green EU resident card) before 31st Dec 2020. This means you are covered by the withdrawal agreement.
It appears that though the EHIC covers you for urgent care while visiting other EU countries apart from Spain, it does not cover you in the UK. You are always advises by the UK Government to take out additional travel insurance.
The new UK EHIC will cover you for all medically necessary, state-provided healthcare when visiting another EU country, Switzerland, Norway, Iceland, or Liechtenstein.
Below is copied from EHIC website
“If you hold an S1, your EHIC will not cover you in the country you live in or the UK”