Nuclear weapon, or the threat of having one, is a reason that Iran and North Korea as still not being invaded.
You are wrong. Iran does not have nuclear weapons. They only are developing and North Korea may pose a threat only to its neighbors so that America is not afraid of them, too. They are not just attacked because they give them a chance for a peaceful solution to this problem.