But the company leadership either has to be able to convince shareholders to stay the course (as Amazon famously did for years without generating profits as it grew), or has to have enough power to ward off the investors (bearing in mind that most investors are institutional not retail) because of the way the company is structured that he's not in danger of being ousted if the board (which represents the shareholders, not the company) doesn't like the company's performance.
Yes, shareholders can sometimes exercise power over a company via its board, but it doesn’t follow that shareholders necessarily want to maximize the value of that company’s shares, or at least not right away. Shareholders often have other interests. For example, they usually own shares in other companies. Also, ESG is big these days.
This can make deciding what a company should do a messy political process when there’s disagreement about what shareholders want or should want. Like, some shareholders may decide to buy a coal plant to shut it down, others to keep it running as long as possible.