I think he made a really bad gamble that pulling out he'd be able to first scare Iran and then follow it up with some late-stage new deal that would be more to the USA and Israel's advantage. Maybe he'll still pull that off. But I have strong doubts. It's his favoured approach that worked with Mexico, is still uncertain with China and seems to have brought us to the lip of catastrophe with Iran.
Worked with Mexico as in... didn't work at all? He just got a new deal that said Mexico would do what they were doing before and has fundamentally no changes in it. Oh I remember, he held up a piece of paper with amazing details on how favourable the deal was but he was keeping those details secret.
As for more hoping to gamble by pulling out and getting a better deal, again, that is not how the world works at all. The whole point of the first stage was too establish trust, prove both sides could stick to what was agreed before taking further steps, pulling out fundamentally breaks the entire purpose of the deal which destroys the foundation for creating a better deal. Also there has been not one moment before the deal or since they pulled out that they tried to push pressure on Iran to sign a better deal.
Trump has failed completely to make any good deals with any country since he's been in charge. He's harmed relationships with almost every major ally, but all his deals, like his deal with North Korea.... his work is laughable.