Germany has excess coal and gas capacity which they can turn on when needed. They, like most people import when it's cheaper than the local alternative.
Interconnected nations all importing when cheap electricity is available lowers costs for everyone.
Looking up the numbers Germany sells high and buys low when it's net importing