Iran never had the deterrent North Korea had. And by being a theocracy they heavily skewed any threat calculus against themselves. What they were doing, inching towards nukes, was a horrible move. In their position, you either sprint covertly and not play at all. I suspect that after their nuclear program was discovered and set back they fell victim to the sunk cost fallacy and convinced themselves they could repurpo…
Religious government or not, Iran has plenty of engineers, statisticians, scientists and intelligence analysts working for their foreign policy and war effort. Your underestimating this betrays prejudice.