Is there a responsible way to buy a residential property Spain as a foreigner?

I'm looking into starting a technology company in Spain, most likely near Barcelona. I have previously lived in the area and speak both Spanish and Catalan decently.

While I think bringing job opportunities and paying tax in Spain would be positive to the country, I realize that coming there as a "wealthy foreigner" can exacerbate the housing affordability situation. I'm especially concerned about getting a place and then just live there part of the year in the beginning.

So my question is: Is there a responsible way to buy residential property in Spain as a foreigner? That doesn't contribute to the housing crisis or make my new neighbors hate me.

Like, buying in a certain area, for example further away from the coast? Or somehow (how?) ensuring that the property isn't empty when I'm not there? Or building a new house rather than bidding for existing houses? Or renovating a house in very poor condition?