This is bullshit. I'm dev from Barcelona (Catalonia, Spain) and the squatting topic is periodically being pumped up by the same dumb bastards (always the same companies and media). Squatting exists at the city but it is not an issue in the daily lifes of Barcelona and Spain citizens, only for the fucking big owners with more than 10 flats each. Squatting happens because this bastards (big owners) are inflating the flat prices and getting the people of Barcelona out of their neighborhoods and giving the homes for temporal tourists.
Demand of people is the only way of inflating the prices. The people who would like to live in Spain, both Spanish people and non-Spanish, are the people who make your country as rich as it is.
Am I hearing you saying "What rich? we have poor economy". Yeah, prevent people from investing in real estate and you'll be even poorer.
We are getting poorer because people invest in real state to their benefit without adding any social value to our lives. Only to higher our rent and making touristic flats. Which crowds our streets with noise and filth while the benefits are for foreign companies that are prostituting our cities like a thematic park.