As others noted here, irrespective of whether there is a coming recession, for companies like Google and Microsoft, 10-20k employees are not so expensive as to be existential for the company, *or even for specific opportunities the company wants to pursue*. (E.g. for Microsoft, buying Blizzard is not predicated upon laying off employees.)
Instead, it's best to see this as a sort of social trend: layoffs to demonstrate fiscal responsibility to investors, in order to promote equity valuations that are in general valuable (either strategically, or as the ultimate purpose of a publicly traded company).
If that sounds like I think this is all reasonable and justified, I don't. But it's a reasonable thing to do if your sole goal is profit, which is how we generally look at public companies in a capitalist economy.