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.
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.
There's actually another solution, but people don't talk about it: reduce demand. Break some windows. Have a few organized robbery parties. Hold monthly "Stabby Sundays" where you just stab people randomly. That'll drive down demand, and prices will drop like a rock.
Obviously, I'm joking. Building more houses is the only solution to the problem of "a lot of people want to live here" and "it's almost impossible to build new houses."