I believe the government could have introduced some emergency legislation to temporarily change the basis of calculating the wholesale cost of energy. If you compare UK electricity prices with EU countries, our prices were higher than everyone else’s during the period of high costs, and not only that there was huge variation country by country, so surely if it was all the EU’s fault as you suggested, they’d all be paying similar amounts to us.
There’s also a reasonable chance there were force majeure clauses in the energy supply contracts that could have been invoked.