With Japan, they had seriously begun the process of industrialization in the 1800's with the Meiji Period [1]. So even though their economy and infrastructure was gravely damaged during WW2, they could rebuild quickly.
With South Korea, I don't know. It was a much smaller country. Being a close ally of the USA may have helped with foreign investment which allowed them to climb up the value curve very quickly. I found this on post-WW2 South Korean economic development [2], but haven't gone through the whole thing yet.