Let's say that it's year X and you have two choices: either you bet that the future will be bleak, and cut cost and hunker down, or you bet that the future will be bright and make big investments.
If X is 2022, the first bet will be right, while the second will lead to bloat and excess. But if X is 2014, the second bet will be right and the company will gain market share, while the first bet might make you go out of business.
So big tech companies weren't so irrational to make those big bets to begin with, and they simply overcorrected the other way around afterwards.
Now, as an employee in one of these I still think this is shortsighted and will damage them long term. But the stock market keeps rewarding these companies handsomely, so what do I know?