There are two, more obvious, reasons for layoffs.
1) The valuation bubble bursting is a big factor. Both high valuations and hiring decisions were made with a certain amount of growth in mind. Now that it's clear that the old level of growth is unrealistic going forward, valuations are coming down to reflect that, as is employee head count. Additionally, employees hired at the sky-high valuations are going to be disgruntled unless they're "made whole". Easier to just let most of them go and top-off the ones you want to keep.
2) There are two types of tech companies. The first is a company like Google, where their tech enables a step-function increase in human productivity. Google Search gave people a super power they never had before. This type of company is extremely valuable as they can capture the value of the productivity they unlock. The second type of tech company is something like WeWork. This type of tech company is essentially a digital version of something that existed previously. These companies can gain traction due to the convenience factor unlocked by the digital transformation, but there isn't much extra value to capture. When interest rates were 0, VCs and the market as a whole were valuing these companies the same as true tech companies. Now that investors are more discerning with their money, the valuations of such companies are popping. The valuations are lower because the true value of the company is low. If you have a low value company, you don't need thousands of employees all earning 6+ figures to run it.