If you look at the terms and conditions of your travel insurance you will probably find that you are expected to go to Spain's equivalent of our A&E first and use the EHIC. Once treatment needs to go beyond what is covered contact the Insurance Co and they will go ahead to pay any further bills.
Below is quote from Which website:
Some insurance policies state they won’t pay out for expenses that would have been free with an EHIC. In addition, many insurers will waive the excess (usually £50-£100) on claims for medical treatment if you have used your EHIC.