Maybe the horror was always inevitable. Maybe the U.S. invasion of Afghanistan could end only one way: with U.S. military planes lofting away as the hands of desperate Afghans were ripped free and bodies plummeted toward the people we’d left behind on the tarmac. Maybe this became inexorable the moment we decided to invade the graveyard of empires.

This is basically the argument of President Biden and his defenders, and it has some undeniable truth. Just as Afghanistan refuted the Soviet delusion that communism was the future, it has rebutted the American fantasy that there is a functional liberal democracy inside every theocracy or dictatorship, just waiting for us to let it out. Ethnicity, culture and religion are fundamental elements of human nature that have to be acknowledged, not engineering problems that can be solved.

The U.S. government spent two decades trying to tinker around these facts and ended up with a “nation” that had too little state capacity to ensure that soldiers stood their ground against the Taliban. Given that, Biden defenders are probably right that withdrawal was always going to be an unholy mess. Even if the evacuation could have been handled a lot better, the question was still likely “when,” not “whether” — and the answer probably “sooner better than later.” Better still, perhaps, if we’d listened to the critics who urged against taking on such a hubristic project in the first place.

But if so, we should consider that possibly our mistakes were just as inevitable as the suffering they caused. Americans, too, have fundamental characteristics that are not easily overcome, and that nature made the invasion nigh-inevitable after 9/11. After which, arguably, everything else followed, as night to day, for 20 years.

When someone attacks you, it is human to want to hit back harder. There’s a rationality to this, since it deters people from attacking in the first place. On Sept. 11, 2001, al-Qaeda killed nearly 3,000 Americans. The Taliban had been sheltering al-Qaeda. And so in October 2001 a Gallup poll showed that 88 percent of Americans supported invading Afghanistan, even though most Americans seemed to doubt even then that we would succeed in removing the Taliban from power, much less capturing Osama bin Laden.

Once in Afghanistan, however, it was unlikely that we could resist expanding our brief. People fight wars for many unlovely reasons — revenge, or status or to steal another group’s stuff. But we humans seem almost compelled to ennoble our wars with a thick overlay of idealism. Even the Roman Empire insisted that it was merely defending itself as its armies spread across three continents, and the treasure poured in.

For cultural and historical reasons, Americans prefer to think of ourselves as fighting for freedom and democracy, just as we did in World War II. And people in general like their actions to match their words, so the more we insisted that the Afghan conflict was about the freedom-loving United States vs. Islamo-fascist Taliban, the less likely we were to stick to a limited, achievable set of objectives.

Even if you are prepared for the reality that liberal democracy is a project of decades or centuries, not months or years — and collectively, we weren’t — grandiose ambitions and indefinite timelines make it hard to recognize when you’ve failed, much less take corrective action. Humans resist acknowledging that they’ve poured time and effort into a failure; instead, as long as there is any reason to hope, they are prone to double down on their failing strategy. Perversely, the more it has cost them, the harder it is to walk away.

Eventually, of course, the inescapable conclusion can no longer be evaded, yet even then the very magnitude of a disaster may tempt people to keep going. If withdrawal was going to be a disaster, that meant horrible political optics for whichever president presided over it. Even when they could no longer fool themselves into believing we were one surge away from victory, the temptation was strong to pass the buck to a successor. It’s to Biden’s credit — and Donald Trump’s — that they actually went through with it.

That’s not an excuse for leaving before making sure that American citizens, and the Afghans who worked for us, got out safely. Nor for the pointless suffering we inflicted on many Afghans during all the years we were there. But that too is human nature at its most fundamental: Even with the best intentions, we are rarely as good as we ought to be, much less as good as we think we are. The only thing that saves us is that we do, sometimes, learn to expect better of ourselves — though usually only after we’ve exhausted every worse possibility.