Large tech companies don't exist to serve as employment programs for software engineers.
If they believe it will increase profits without longterm harm then layoffs/salary freezes are the right thing for them to do as a company even if they are wildly successful.
Layoffs are frequently done when a company is struggling, so people seem to think it's incongruous for a company to do layoffs if they are doing well.