Not sure if Apple is an example of 'most companies.' Apple was a tech miracle, and it's led by essentially the most or second most famous tech CEO, ever, Steve Jobs. Mayer is not Steve Jobs but then again, nobody is Steve Jobs other than Steve Jobs. For internet companies like Yahoo, there are thousands more examples of those that failed than those that succeeded. Very few internet boom companies from the late 90s are still around, failure, aggressive downsizing, or acquisition is the norm, not independent, continued growth, and success.
Mayer also made some very good decisions. Virtually all of the value in yahoo is with Alibaba, the Chinese e-commerce megalith and it was a really brilliant purchase that she pushed for.
The Work-from-home policy had bad optics because Mayer, being a woman, looked like she was preventing other women from being successful employees and mothers... But if you know anybody who has worked at Yahoo 5+ years ago, you knew it was a major problem there. Employees who hadn't been in an office in 6 months, who stopped replying to email, who stopped doing anything, yet were at home collecting $80 and $90,000 salaries doing as close to nothing as possible, across the whole company. Yahoo lost some talent on that gamble, but they helped cut a lot of waste, and it was also during a time when many tech companies were shifting back from the aggressive work-from-home culture of the bubbled-mid 2000s, and after the financial collapse.
It seemed inevitable at least 3 years ago that Yahoo was simply looking to sell the company at the best share price. Shareholders simply wanted the company to sell, as they couldn't compete with Google, Facebook, and others, in their only profitable internal businesses like ad marketing. Mayer's job for the last 3 years has been effectively to sell the company and sell herself out of a job. She's out not because she failed at running Yahoo, but because she's failed to sell the company.
It was also a hostile takeover attempt, or "unsolicited shareholder buyout." Not exactly a business decision for Yahoo.