I would argue the solution is build a lot of affordable housing. I've noticed in Berlin, a lot of new development follows a pattern: small footprint apartments with luxury amenities. This is great if you're a landlord, and you want to maximize the revenue of your property. But it's terrible if you're just looking for a safe, clean place to live, and you end up paying double the rent because luxury units are the only thing available.
Small, luxury apartments are going to be more profitable than something more affordable. Landlords will build the most affordable thing they can, to do anything else would be irrational. If only luxury apartments are being built, that means demand for such apartments hasn't been satisfied yet. The solution is to allow MUCH more building, so that something affordable will eventually be built. Even without that, having luxury apartments prevents the renters from competing on more affordable units, so it likely does have a positive impact.
I don't know anything about Berlin, but in San Francisco, there are plenty of affordable housing requirements placed on developers of new apartment buildings. This ends up just making new construction MUCH more expensive, as a single unit has to support itself as well as some fraction of an affordable unit. The result is that it's even less profitable to build new housing.
I don't agree that the free market is the only way to allow for more affordable housing, or even a good one. To some extent, housing has inflexible demand. If you work in a city, you need to find housing at least within commuting distance of that city. Because of this, landlords can build tiny palaces, and people will pay 50% of their income or more to live there, even if they really want affordable housing. In some sense, you could argue that real-estate developers can operate like a cartel and control the supply of affordable housing.
One clear alternative to this public housing. In Vienna, for example, about a quarter of the population lives in social housing. And these are poorly maintained slums, these are nice, well-located and affordable apartments. The city/state can optimize for the actual housing needs of the city rather than for profit.
I would argue that housing, much like healthcare, can function better when managed as a public good, as there are too many perverse incentives at play when there is a profit motive involved.