Letting people get rich off holding people's basic needs for ransom is never going to be part of the solution to homelessness.
The whole thing is complicated by being geographically unequal: for example I think even Spain is full of affordable houses, only they are not in Madrid or Barcelona or Valencia, which is where people really want to live. So if you have a second house in an unpopular town you actually have not much - thus you are not rich - and you have often an empty house (nobody wants to rent/buy it) which is an easy target for squatters, and therefore you will become "one of the poor people ruined by squatters", while othen you are somebody who accepted the narrative that using houses as investment was a good idea, both an investment house cheaply in a town that never attracted enough people, thus "lost the game" and is now also losing the house to squatters...
As an example, we bought our house for $280k in Iowa seven years ago. It held steady for a bit, but jumped up to close to $400k shortly after Covid. YIMBY policies in my area could cost me as much as $120k of wealth that I now possess. What percentage of home owners are going to willingly give up tens to hundreds of thousands of dollars in wealth to support more equitable housing? Even for a liberal, $120k is a hell of a lot of money and it's only growing year after year under our current system. With that equity continuing to grow, maybe I have some hope of retiring in the future? That's a hell of a lot to put on an individual to ask them to support more equitable housing. Other people's suffering is their only chance to not suffer constantly until they die. And when you think in terms of not just my suffering but my family suffering, it becomes a lot easier to slip into NIMBYism.
How do you decouple primary housing from investment without fucking over literally millions of homeowners who have done the best they can under the existing rules? It's something I'm personally interested in. But I also don't want to be working until the day I die. What is the compromise that satisfies the majority of people?
So the speculators set up a company, buy the property and list it on AirBnB at several times the market price. Now it's not an empty property, it's a business. Business is slow so they only have to bother with guests during spikes in demend.