A government’s source of revenue is working age taxpayers. Its biggest cost is the social safety net for the elderly. It seems natural for them to care about population growth? Where would they get the money for UBI if their tax base is contracting every year?
Immigrants (at the scale Spain needs) don’t want to move to a shrinking economy. Spaniards themselves are leaving the country to look for work. As an example, Central American immigrants will immigrate through multiple low growth countries specifically to get to the U.S. for work.
To GP’s point though, I think Spain’s population problems aren’t all that related to dense apartments and more tied to economic opportunities.