Most boards(particularly of large publicly traded tech companies) don't hire CEOs to ensure their companies remain stable in the longterm at the expense of profits, they hire them to grow short term profits.
Boards don't see the over-hiring as a mistake. On the contrary, had CEOs not moved to grow their companies relentlessy and pursue profits in the years during/after COVID when tech was booming, their boards would have fired them. Now that times are leaner, they need to rein in spending to maintain profits -- if they dont do that, then they'll be fired.
I think it depends on the company. I don't know how bad of a problem it is for big businesses like Amazon. Sure there's some lost profits and a write-down with the layoff, but it's not like Amazon hasn't been successful and profitable in the meantime. The overhiring may be justifiable as a defensive strategy.
I was at a smaller public company that overhired during COVID then struggled with profits (among other things). CEO and leadership lost a ton of money due to the share price drops from COVID peaks and CEO was ultimately pushed out.