Spain can't get excess solar or wind energy to a wider market, with the very minor exception of Portugal. The reason is that France has de facto blocked high capacity transmission crossing the French/Spanish border, thereby preventing excess Spanish renewables from undercutting French nuclear. This acts to protect French nuclear both in its domestic market and its its natural adjacent markets. One can have long complicated debates about whether this should be permitted, but it is the reality. The practical upstream effect has been to inhibit the gowth of a solar and wind manufacturing industry in Spain, beyond that which might be justified by its domestic needs. As such this means that manufacturers in Spain have not been able to reach the necessary scale to compete with the Chinese. (Offshore cables might debottleneck this, they are endlessly proposed).
Despite that Spain has done a pretty fair job on decarbonisation so far.
La Moncloa. 27/12/2021. Spain meets European targets for renewables and energy efficiency in 2020 [Government/News]
The Spanish car plants can get their products to markets via rail and/or sea without a commensurate level of French throttling. These car plants have had both good and bad patches. Other good car plant candidates within the EU apart from Spain and which have the necessary size to asorb a Tesla facility, and cost-effective workforce are Poland (but a bit close to Germany), Bulgaria or Romania. Outside EU one could propose Ukraine (good, apart from a war) or Turkey (iffish under Erdogan, almost uninvestable) or UK (nightmare post-Brexit, don't go there). Perhaps Hungary (nightmare politics with Orban). All European governments will have the taxpayer cheque book at the ready.
Personally my bet is that Brazil is next up on the board. However I note that presidential elections are a two round affair and will take place in October this year. I have my head in my hands at the thought of a Bolsonaro vs Lula choice. Later this year might mean after that election has concluded.