Investment in housing (ie actively rented places) are unaffected, so there is no reason there woukd be less investing on that front
See for example:
https://m.murciatoday.com/almost_half_a_million_vacant_new_b...
https://www.investigate-europe.eu/en/posts/the-empty-house-a...
It isn't a particularly Spanish problem either: following article about the American version of it
https://www.cbsnews.com/news/empty-office-buildings-doom-loo...
Are those the evil investors who should be punished? Now they are homeless instead
If that happens you call the police and they'll kick them out in 24 hours max.
Now if the current renter can't afford to keep paying rent and decides to occupy the property, that's considered Okupación. And that process does take longer.
Morada is any property that you live, use to live or use to do private activities in it.
If you used at least once a year or so, then is morada. Like if it was your primary house.
If you have a semi demolished house, or unused house during years, then clearly is it not a morada. That's the difference.
Sticking to Spain, there were about 17,000 squatting incidents (reported to the police) in 2021 [1]. I don't know about big cities in Spain, but e.g. in Berlin there are tens of thousands of squaremeters in unhoused space in form of offices and high-rent appartments. Do you really think people go to the homes people live in first?
[1]: https://maldita.es/malditateexplica/20221026/datos-okupacion...
However after some years, the situation slowly changed: more and more squatters were drug addicts, who ofc couldn't afford to pay rent; also the word spread outside of NL that it was possible to go to Amsterdam and live there for free, so loads of immigrants came with no intention to rent at all.
Apart from that, squatting exposed another problem: the squatters typically didn't care too much about their home or neighbourhood, after all it was not theirs and sooner or later they'd have to move out again. So they typically caused a lot of irritation with their neighbours because of garbage of noise. In the end, squatters in NL lost most of the goodwill they had with the Dutch government, and stricter anti squatting laws are now in place.
But from a societal standpoint, the laws being this way have a bunch of positive externalities
1. It provides shelter to the homeless, with all the advantages we know that has
2. It provides an incentive to not leave property vacant. Very important in a country with high vacancy rates 1nd a hiusing crisis.
Note also that this is done at the expense of investors. Whose role in a capitalist society is to take on risk.
So while it is an injustice, i can definitely understand why it is this way.