There are additional rules for critical national infrastructure. The gas company didn't follow them and this gave the government the legal right to seize the business.
Honest question: Then why did they (Germany) allow Gazprom to own critical infra. in the first place?
Honest answer: Because they were following the rules up until that point.
This is probably one of those circumstances where law gets so complicated that you are always in violation of something. That way, when the authority needs you in one way or the other the haul you in front of a judge for your "violation of the law" unless you cooperate with their demands.