Fiduciary duty is a real thing. Agent/principal relationships require the agent to try and get the maximum return for the level of risk.
Even if a CEO doesn’t have a written fiduciary duty in their contract do, the company as a whole usually does.
The CEO of a public corporation reports to the board who report to index fund managers who have a agent/principal relationships with all of their investors.
Your examples are not counter points to the original claim of
Any public company is LEGALLY REQUIRED to care only about profits. It is literally illegal for them to do anything else.