Energy is only one reason for the Russian invasion of Ukraine. But it is an important reason. It’s not in the interest of Russia for a major alternative energy supplier for Europe to emerge. Ukraine enjoys major untapped energy deposits coupled with already existing pipeline infrastructure into Europe.
Despite this it is not likely to become an energy supply competitor to Russia. A quick look at the following two maps shows that Russia’s occupation overlaps with much of Ukraine’s oil and gas reserves. Supplies around the Crimea and eastern Ukraine are a big reason for both the Russian invasion and Ukraine’s resistance to trading land for peace, since in this case the land in question could be the difference between being a wealthy or poor country for Ukraine.
A lot may have gone wrong for Russia in Ukraine. But one thing that has gone right is that Russia is now well positioned around Ukrainian energy and can keep Ukraine from tapping into them and becoming a wealthier independent country and a significant energy competitor in Eurasia.