1) In early 2000s the then government (coalition of Social Democrats and Green party) decided to end nuclear and to fully transform the country to renewable energy; the Greens are heavily influenced by 1980s anti-nuclear movement. I still think that this decision was mindblowingly progressive and valuable at that time. As a "bridge technology" they wanted to use natural gas (hence the good friendship between ex-chancellor Schröder and Putin).
2) The Merkel-led gov't in 2010 (coalition of Conservatives and Liberals) decided to prolong nuclear (no real reason, imho more of a "we know better").
3) Fukushima happened in 2011. Germans were concerned in surveys and Merkel (imho stupidly) decided to make nuclear's deadline even earlier (end of 2022) causing huge fees the gov't had to pay to energy companies (afair 1-2 billion EUR). Running plants were shutdown between 2011 and 2022. Meanwhile Germany's dependence on cheap natural gas imports from Russia went up. Chemical Industry, electrification and warming were the main uses. I think they doubled or so at that time.
4) Putin invaded Ukraine. Sanctions on gas exports (imho rightly) happened and gas prices skyrocketed. Putin completely turned off the gas. The current gov't (Social Democrats, Liberals and Green party) had to decide on what to do. So they decided to build LNG ports and continue phasing out nuclear which at that time only contributed around 6% to electrical power because all the other plants were already shutdown.
5) They still needed to find a way to produce electric energy in case renewable energy is not available (due to cheap Russian gas there was zero incentive to create waus to save energy) so they're now burning coal and heavily need to buy CO2 certificates and bet on that it will get so expensive that energy companies will invest heavily into renewables.
The signal though is horrifying. I hate everything of this typical German kind of stupid compromises.