We should not expect companies to choose a less immediately profitable route that ensures long term sustainability. That's just not what they are incentivized to do on their own. Consumers can sometimes influence those incentives, but there is not always enough market choice to put that kind of pressure on corporate behavior. Instead, if there is a significant public interest in such a change, such as with climate change from burning fossil fuels, it is up to governments to change those incentives.
If green energy is less profitable than fossil fuels, the government can cap production, increase taxes, rework trade deals, add regulations, etc. to limit the profitability of fossil fuels. They can also increase the profitability of green energies by providing grants into research, tax breaks to producers, tax incentives to adopters, subsidize installation and maintenance for green energy production, fast track infrastructure, etc.
If fossil fuels companies can make an easy buck by switching to green energy, they will or someone else will outcompete them. But while they can still profit off more off of the thing that is worse for the world, they'll still do it becuase the profit is the goal. Always. Duh. Welcome to the horrific consequences of unfettered capitalism.