Because they overhired during 2021/2022. Look back at the news discussing The Talent Wars from that time. Most companies were hiring because money was easy to come by. Most of these engineers salaries were paid for with debt.
When debt is used correctly, it’s a tool for growth. You can take out a loan, hire an engineer, build a new feature, and bring more money in than what you were before. The loan pays for itself.
The problem is that a typical engineer takes 6-12 months before they are a net-positive to the company.
Now that companies can’t get debt for free, they can no longer support the engineers they recently hired.
That doesn’t mean that they always layoff the people they recently hired. It’s possible that the investment could still pay off. Instead, they can decide to layoff other teams that aren't providing good returns.