Those two nations still had the right culture and social structure to build blooming new societies. In this context, with "culture" I don't mean political views or such, but work ethic, and things like literacy, education, etc.
The German car industry wouldn't have been thinkable hadn't the Germans invested a lot of research into building machines in a mass produced way, motor research, etc. Sure, the factories themselves were destroyed, but the engineers together with their knowledge remained.
In fact, there are theories that disruptive events are even helpful for economic progress in the long run because they filter out the lazy elite of rich people while giving opportunities for new ideas to be tried out, and hard working people to rise to wealth and influence.