North Korea was a limited victory and didn't just involve the U.S. There were 16 NATO countries that sent combat troops and 23 in total sent various assets, e.g. military medical personnel. Nobody wanted a WW3 that would've happened had we kept NK. It's China's buffer nation in that area and taking it further than that would've been disastrous.
The same applied in Vietnam. If the U.S. had chosen to go to Hanoi and destroy that government, it could've done so in a matter of a few months, if not less. However, doing so would have assured a much wider conflict that nobody wanted.
Iraq: same concept as above. Had we ruthlessly destroyed Baghdad and other major population centers like we did with Japan and Germany it wouldn't have taken long to pacify it. Also, the idiotic de-Baathification policy only served to make things more difficult than they needed to be.
Since WW2, U.S. military policy in relevant conflicts has been one of restraint due to changing global circumstances. We did indeed beat NK's ass until China showed up, but then we beat them back as well and could've gone all the way to the Yalu, but again, that would've meant a wider war when the Korean War by itself was already unpopular.