They only have the funds to do that because of wealth inequality. This is downstream of the massive growth in inequality.
Needs a wealth tax. Make holding more than 10m euros worth of property a yearly expense and the foreign speculators will invest elsewhere, and prices will come down.
Also the spanish budget will get a break.