How come Spain didn’t conquer Portugal at any point in history?
Spain did not conquer Portugal in any formal sense of the world largely due to the fact that Spain as a nation has only formally existed since around the 15th century. Before this, Spain was divided into a number of kingdoms which were all vying for absolute control of the peninsula but could never fully do so. Portugal was one of the strongest of these kingdoms and used a highly trained army along with a strong alliance to England to ensure that other Iberian countries could never fully invade the country.
By the 17th century, the Portuguese and then Spanish royal families had become deeply intertwined through arranged marriages and so were rarely in a position to justify or even want war between the two states.
In all, Portugal’s strong military and diplomatic ties led to it being able to largely remain protected from other Iberian kingdoms attempting to invade whilst also later using marriage ties to create a connected and cooperative relationship between the Kingdoms of Spain and Portugal.