During President Donald Trump’s announcement that the United States would be leaving the Iran nuclear deal, he could not stop himself from mentioning that his secretary of state was on his way to North Korea. Mike Pompeo would be preparing for the president’s upcoming meeting with the leader formerly labeled “Little Rocket Man.”

The juxtaposition of the two countries was no accident. Mr. Trump seemed to say, “Trust me with Iran; I know what I’m doing.” Indeed, two days later, Mr. Pompeo returned to the United States with three American prisoners from North Korea. Kim Jong-un had released the men into his custody.

Later that day, the president tweeted that the meeting with Mr. Kim would take place on June 12 in Singapore: “We will both try to make it a very special moment for World Peace!”

Mr. Trump deserves credit for bringing Mr. Kim to the table. Perhaps the bombastic exchanges between the two leaders will somehow lead to an unprecedented understanding between North Korea and the United States. And pulling out of the Iran nuclear agreement could, in theory, result in a better deal with Iran somewhere down the line.

In both cases, it is early in the game. There is no deal yet with North Korea, and it remains to be seen if Iran will continue to honor the nuclear agreement with the remaining signatory states despite the imposition of U.S. economic sanctions. But beyond relations with Iran and North Korea, the way Mr. Trump is wielding economic and military power will come with collateral costs.

The United States left China, Britain, France, Germany and Russia in a very difficult position by stepping away from the Iran deal. Even if unpredictability and the willingness to walk away from commitments can break stalemates with North Korea and Iran, such actions tarnish U.S. credibility in future multilateral efforts.

Beyond relations with Iran and North Korea, the way Mr. Trump is wielding economic and military power will come with collateral costs.

Mr. Trump, who in his business endeavors often capitalized on short-term gains, may not be concerned with the status of the United States in 10 years. But U.S. citizens should be. Misguided foreign policy decisions can reverberate for decades.

President Ronald Reagan approved repeated interventions in Central America. Thirty years later the region is mired in poverty and violence. President Clinton’s insistence that Haiti drop rice tariffs devastated the Caribbean nation’s agricultural sector. And the Middle East is still reeling from President George W. Bush’s decision to invade Iraq and topple Saddam Hussein—an action that benefited Iran in the end.

Iran’s ongoing support of Hezbollah and Hamas merits a change in course. Yet Mr. Trump could have heeded the advice of President Emmanuel Macron of France to negotiate with Iran without walking away from the existing agreement. Together with U.S. allies, Mr. Trump could have helped Iran develop a more stable economy, the surest path to peace.

Being unpredictable sometimes leads to a better deal in business, but walking away from international commitments foments mistrust among allies. U.S. foreign policy cannot become a showcase for one administration’s presumed deal-making prowess. If things fall apart, the United States does not get to file for bankruptcy and start another country.