It's a complicated one, but legally it's a civil contract; if the Ukrainian government decided to stop the gas flowing, both Gazprom and all the companies "downstream" would be in their rights to sue for breach of contract and/or causing gas shortages, costing the Ukrainian government billions.
And you could wonder why they signed the contract anyway given Russia invaded/annexed Crimea 5 years prior, but, it's a lot of money, and at the time it was still considered a civil contract I presume.
Ultimately the general public is capricious in its beliefs: cutting the gas off and causing energy prices to spike in Europe means someone will call for the head of whoever's nearest to blame.
Ukraine also was deliberately not targeting Russian oil assets earlier at the request of the US for economic reasons - though I'd say recent American political history shows what a mistake that is.
I find this fascinating: the US is a net oil exporter so 'as a country' would benefit from higher oil prices.
But it seems in the US your average Joe who tops up his car at the petrol station has more political power than the oil industry.
Pretty much. A common absurdity is politicians railing against Big Oil for causing climate change while simultaneously promising to lower gas prices.