Flaw in EU energy law helped gas industry pocket €1 billion of taxpayer funds