In fact, Trump had privately indicated that he would seek to withdraw from NATO and to blow up the U.S. alliance with South Korea, should he win reelection. When those alliances had come up in meetings with (Defense Secretary Mark T. ) Esper and other top aides, some advisers warned Trump that shredding them before the election would be politically dangerous.
It is open to speculation as to why Trump would want to sever ties with NATO and end the U.S. relationship with South Korea.
Certainly the first would please Putin. and the second would make Kim happy. It isn’t only wanting to make these dictators happy that would have led Trump to doing this. It is that he thrives on being a disruptor, that he takes pleasure in exercising his power in ways that appall his enemies.
He is a world-class grudge holder and sucks off the teat of revenge. To him every NATO leader with the possible exception of Erdogan of Turkey hasn’t shown him the deference he believes he deserves.
The widely panned visit to North Korea must have smarted when Kim used him as a propaganda tool (and played him for a fool), and continued to expand his offensive weapon capacity. I am sure he'd dearly love to make nice with Dear Leader and get some bragging points if North Korea made some showy (but meaningless) concessions to denuclearization.