A handful of nuclear weapons won't keep a country safe. They would also need a credible second-strike deterrent.
Relations between sovereign states are fundamentally anarchic. There are no world police. The UN and other international institutions have little or no real power, and the Non-Proliferation Treaty is only enforceable through kinetic action by other countries when it suits their interests.
NK can have a handful of submarine-based missiles that threaten to wipe out say Seoul or LA for example, even after the first strike. It's not a guarantee by any means but it does raise the bar and would probably prevent a situation like the current one.
NK kept itself safe for decades with just a lot of artillery aimed at Seoul.
Second strike weapons are in some ways a holdover from Cold War strategic thinking which it's sort of acknowledged probably overestimated the penchant of any side to engage in a first strike.
The practical reality of nuclear war planning has generally been that no one will accept even a single city-buster landing - and no first strike option is really reliable enough to guarantee you didn't miss one.
Relations between sovereign states are fundamentally anarchic. There are no world police. The UN and other international institutions have little or no real power, and the Non-Proliferation Treaty is only enforceable through kinetic action by other countries when it suits their interests.