Not certain if this is the correct sub to be asking this question since it is all relatively recent history, but I was curious how North Korea was able to achieve their goal but Iran, which is less economically isolated, was not able to build one
It's not a matter of capability, it's a matter of effort. Iran's nuclear program was a very small thing up until the 1990s, and it stopped in the early 2000s. North Korea has been seriously working on getting nuclear weapons since the 1970s, and only slowed at times, never quite stopping. That's a big difference in this area, if you are trying to have a reasonably small program that isn't easily detected.
Separately, North Korea has been somewhat insulated from foreign intervention (other than sanctions and maybe hacking) compared to Iran (who has suffered assassinations of its scientists, cyberattacks, and full-on diplomatic difficulties that have been hard for it to ignore) because North Korea held South Korea over a barrel even before acquiring nukes (their ability to destroy Seoul effectively deterred the United States from taking any kind of military action against them).
It's not about technical knowledge or know-how (the Iranians likely outstrip the North Koreans in that) or about resources (ditto), but the duration of sustained effort.
Anyway — as much of this gets beyond this subreddit's 20 year rule, and much of the details are still unknown, it is hard to be more than evocative about the differences, but the Iranians and North Koreans have had very different nuclear programs. And, again, it is worth emphasizing that the Iranian weapons program was very short in duration — it effectively stopped in 2003, having only started a decade before then. That by itself is a huge difference from North Korea.
For information on the early histories of these programs, see Jeffrey Richelson, Spying on the Bomb.