According to this, you cannot use your EHIC for NHS treatment in the UK as free NHS care is residency based and you are no longer a UK resident. You will have to use travel insurance.
Also, within the first 5 years of residency in Spain you are limited with the amount of time you can spend outside of Spain. It is 6 months in any one year and a maximum of 12 months overall otherwise your residency will be cancelled.
https://www.immigrationspain.es/en/maximum-time-outside-spain-without-losing-residency/