A last-minute decision to be married before a baby is born. Being married can simplify other bureaucracy if the mother dies or is incapacitated.
I think most immigrants who get married in Germany are doing it for legal reasons primarily.
And in actual emergencies, these processes can be accelerated, like every other buerocratic process in Germany