No, we can’t explicitly establish that. It is of course true that many squatters do so out of financial necessity, but others do so for other reasons: a lifestyle choice, a political choice, or plain freeloading and financial gain - in a squat in my village there were people living there with full time jobs and driving brand new Audis!
I would add further that the responsibility of paying the utilities and tax falls on the building owner even if it is occupied by squatters.
None of this diminishes the fact that housing is increasingly expensive in Spain, particularly in Madrid and Barcelona, and this is causing real problems.
But the situation is definitely more complicated than just ‘build more houses’.