it happened because the market was pushed way out of equilibrium with costs of borrowing artificially low for far too long.
Fixing this is going to take years since those people with 2% mortgages are not going to let them go quickly. Now that borrowing costs are much closer to normal, the market can slowly move towards equilibrium again. But it won't get there until this chart flips back to historical norms where it's cheaper to buy then rent again.