Well, partly companies behave that way out of anticipatory obedience: if they were to really focus on the long term at the detriment of short-term profits, you'd bet that at least some (maybe influential) shareholders would protest. And partly of course the CEO's compensation depends on the shareholders being happy, not on the long-term viability of the company, so there's that...