Trump criticized Spain for its low defense spending and suggested Spain's belonging to the BRICS, a group of emerging economies.
Spain spends 1.2% of its GDP on Defense, being far below the 2% it committed to, and even further from the 3-5% that Trump would prefer.
A trade conflict between the US and Europe would harm Spain, especially the most exposed regions such as the Basque Country, the Valencian Community, Catalonia, and Madrid.
The Spanish government, despite ideological differences, is forced to strengthen bilateral relations with the US, both for commercial interests and to reaffirm the Atlantic commitment.
Conclusion: Spain's behavior and decisions in the field of Defense and Geo-politics can influence its relationship with other countries, in this case, with the US, and have consequences for its economy and national security.