History suggests three ways to prevent a state that has the capacity of going nuclear from exercising that option. The first is a security guarantee in exchange for denuclearization. The former Soviet republic of Ukraine took this route in 1994, when it gave up its extensive nuclear stockpile and joined the Nuclear Non-Proliferation Treaty upon a promise of respect for its territorial integrity from the United States, Britain, and Russia. In different ways the United States has provided security guarantees to other potential nuclear states that have kept them as non-proliferators such as Saudi Arabia, South Korea, and Turkey.
The second way to prevent a state from going nuclear is to conquer and occupy it, to reconstruct its regime, and to become an ally and a security guarantor. The United States followed this road, in effect, with Germany and Japan after World War Two, although it certainly did not anticipate the new postwar nuclear reality when it entered the war in December 1941.
The third way to prevent a state from going nuclear is to destroy its nuclear reactor by a military strike. So Israel prevented Iraq from going nuclear by an attack in 1981 and prevented Syria by an attack in 2007. A variant is the credible threat of military attack, in short, deterrence. This course persuaded then-dictator of Libya Muammar Gadaffi to give up his nuclear program in December 2003, after the American invasion and conquest of Iraq.
In its deal with Iran, the United States has exercised a combination of a security guarantee and deterrence, but only to a limited extent. By withdrawing sanctions and allowing Iran to return fully to the community of nations, the United States in effect guarantees its security. Iran in return cuts back on its nuclear program temporarily, but the agreement allows Iran to produce a nuclear weapon after 10-15 years. There is plenty of precedent for states to cheat on agreements, and so the time frame to an Iranian nuclear weapon might be even shorter. The only way to stop that would be deterrence, but that will not be easy to put into effect. True, the deal calls for the re-imposition of sanctions in the event of Iran breaking the agreement, but the economic incentives for trade will make it difficult for governments to go back to sanctions. Meanwhile, American withdrawal from the Middle East in recent years suggests anything but a strong military deterrent power. As for the possibility that the agreement will bring regime change to Iran, the deal brings prestige and power to the current Iranian regime, so it is hard to see that changing.
There is always hope, and we should not give that up, but history provides little confidence for Iran remaining non-nuclear.