The stock market's reaction to news that President Donald Trump would withdraw from the Iran nuclear deal showed just how irrational this market is, CNBC's Jim Cramer said Tuesday.

"There are some markets where it pays to be smart, to really think things through," he said. "This market is not one of them. This is a straightforward market that's as dumb as a bag of hammers, and if you want to beat the averages here, the trick is you can't overthink anything."

On Tuesday morning, investors bought shares of defense stocks in anticipation of the announcement, which many figured would heighten volatility in the Middle East — a boon for U.S.-based defense contractors.

But Cramer argued that those investments were simply too obvious. Defense stocks had already been rallying for most of 2018 on tensions between North and South Korea coupled with worries about the Middle East, he noted.

But with North Korea intent on denuclearization, which would indicate progress in peace talks and thus negatively affect defense stocks, Cramer wasn't so sure Tuesday's buyers were making a smart move.

The "Mad Money" host noticed a similar trend occurring in the energy space. Even though the president talked about pulling out of the 2015 deal with Iran for much of his campaign — and many surmised that oil prices would fall if he did — buyers flocked to energy stocks after Trump's speech.

Calling the market "stupid," Cramer said the trends were "almost too good to be true: we got an event that inflames the Middle East and oil [stocks go] higher."

Cramer said he felt like investors who bought oil stocks on Tuesday as though they didn't know Trump would exit the Iran deal were "living under a rock."

"If you had done a lot of homework and you had a good memory, you would've been selling the [oil stocks], not buying them, as would be the case with almost every other market I have ever witnessed. And all that thinking and history and knowledge would've betrayed you as [oil stocks] just roared," he continued.

"This market did the unthinkable: you are not supposed to be able to make money in such an obvious way," Cramer said. "But the obvious is what's working."

Cramer spotted other worrisome patterns throughout the market. Buyers flooded shares of cloud plays like Adobe and Salesforce despite a lack of new developments at either company.

"This market has become really difficult because it doesn't seem to know how to calculate an event," the "Mad Money" host said. "It doesn't know how to discount news. It doesn't know how to game the president. It's ridiculous, but in all my years of investing and trading, I don't think I've ever seen buyers and sellers be faked out so often."

So, as stocks digested the Iran deal news into Tuesday's close, Cramer emphasized how important discipline and conviction are to investors in this market moment.

"Let me give you my bottom line: this is a market made for people who feel, not people who think. I don't want you to let your emotions rule. I think if you stay disciplined about your conviction, you can run out these inanities. If you don't have it, you'll be shaken out time and time again," he warned. "So find a stock you like, wait for the selloff, then buy. And whatever you do, don't try to out-think the action."