A U.S. soldier sits atop his armored vehicle on a road near Manbij, in northern Syria. (Hussein Malla/AP)

History teaches that generals often love fighting the last war. So does our erratic president, who spent this last week doing just that, both on our southern border and halfway across the world.

In a frenzied attempt to appease readers of Ann Coulter columns and Breitbart News, President Trump ordered that National Guard troops be deployed to the U.S.-Mexican border. Trump also forced his homeland security secretary, Kirstjen Nielsen, to pretend that his administration was moving forward with the building of a border wall. But in the process, Nielsen simply ended up admitting that Trump would be doing little more than renovating sections of a wall that existed while Barack Obama was president. Campaign cries of “Build that wall!” have devolved into the ­low-energy whispers of “Add one coat.”

The president’s preposterous immigration proposals come, remember, at a time when border crossings from Mexico into the United States sit at a 46-year low. Illegal crossings by Mexican immigrants have fallen sharply in the wake of the 2008 financial crisis and the steady improvement of Mexico’s economy. Fortunately, lasting damage from nonsensical White House moves on the border should be limited to the deterioration of Trump’s already sordid reputation.

More troubling for the United States’ long-term interests have been the president’s recent policy pronouncements on Syria. Sitting presidents often repeat the mistakes of a loathed predecessor. Candidate Donald Trump criticized Obama’s habit of announcing troop exit plans and promised voters he would not repeat the same mistake, but Trump spent this last week similarly broadcasting military plans to the United States’ enemies. The commander in chief laid bare his hopes for a speedy retreat from Syria to the Islamic State, Iran and other enemies across the region. Future military movements should be the stuff of classified briefings, not some offhand news conference punch line.

“If I win, I don’t want to broadcast to the enemy exactly what my plan is,” Trump said at a September 2016 campaign forum. But this last week, Trump used a multilateral news conference with the leaders of Latvia, Lithuania and Estonia to all but throw in the towel in our ongoing fight against Islamic State.

I want to get out.”

That the U.S. president announced his plan to cede Syria to Vladimir Putin had to be deeply unsettling for those three countries, which are under continuous threat from Russia. But they are certainly not alone. America’s friends and foes alike must be asking themselves what kind of country cedes Iraq to Iran in a catastrophic, ill-planned war; abandons that country in 2011 after returning a semblance of order; sits idly by while 500,000 Syrians are slaughtered; allows, through inaction and neglect, for the rise of the Islamic State; and belatedly crushes the Islamic State’s dream of a thousand-year caliphate — only to once again move to abandon the region, thereby empowering the Islamic State, Iran, Russia and the murderous Syrian regime of Bashar al-Assad.

After years of endless bloodshed, the U.S. military has finally learned to fight an enemy such as the Islamic State in a way that is successful and sustainable. The impact of that winning strategy is being felt around the region, and among U.S. troops. On Friday, The Post’s David Ignatius movingly reported on the emotional stake U.S. service members have invested in their fight against the terrorist group. Despite our long list of tragic missteps in Iraq, the troops Ignatius followed believe they are part of a meaningful mission.

“Contributing to something greater than yourself is very important,” a military surgeon explained. “It’s an honor for us to be here.”

That feeling is shared by most in the field but sadly not by their commander in chief back in Washington. Instead, Trump is preoccupied with an imaginary border war. So the National Guard heads to Texas while our heroes in Syria are forced to come home.

Our troops deserve better.

Read more from Joe Scarborough’s archive, follow him on Twitter or subscribe to his updates on Facebook.