A baby takes 9 months to develop, if you notice 2 days before birth that you should be married so that you don't have to adopt (or whatever other reason), that's just very poor planning on the parents' side.
And in actual emergencies, these processes can be accelerated, like every other buerocratic process in Germany