This 100%. In addition, if you want to look into new factors, the huge amounts of foreign investments that came into Madrid have been dedicated to normal rentals, or to hoarding empty flats; not to short term rentals.
Foreign or national, the fact is that Spain suffered a housing bubble and it’s burst, but all of the legal and political conditions that gave rise to the bubble are still there.
Add the negative interest rates of the BCE, and you have found a nice way to make a killing...
AirBnB and similar players have a small percentage of the rent stock. They can only shift prices on the margin.
If you want the real culprits, Spain has a broken rental law that increases risks both for renters and lenders, and both cities have strict construction limiting codes (i.e. almost fixed supply).