The last thing President Biden ever wanted to do was to preside over another ramp ceremony for more flag-draped caskets returning home from Afghanistan. Indeed, the entire rationale of his troop withdrawal was to avoid further casualties. Yet there he was on Sunday at Dover Air Force Base honoring the 13 service members killed in the suicide bombing at the Kabul airport. Fate can be cruel that way.

No doubt the president was even more gutted than the rest of us, because he was the one who sent them into harm’s way. In one of her last Instagram posts, Marine Sgt. Nicole Gee had been pictured holding an Afghan baby in her arms. “I love my job,” she said. Now she is gone. Along with Marine Lance Cpl. Rylee McCollum, who was married in February and expecting his first child; Marine Lance Cpl. David Espinoza, who hailed from the tiny border town of Rio Bravo, Tex., and saw military service as his “calling”; Marine Lance Cpl. Dylan R. Merola, who wanted to serve his country just like his two great-grandfathers who fought in the Korean War … and so many others.

Their deaths were not in vain. They died so that more than 114,000 people could escape to freedom. Generations as yet unborn will remember these heroes for helping them to find a better life. And yet their sacrifice was also agonizing and unnecessary. Like so many service members throughout U.S. history, they died, in part, because of the blunders of their superiors.

If you ask me who is to blame, I would point not only to Biden but to former president Donald Trump — and to all of us, the people of America. By carrying out this pell-mell withdrawal from Afghanistan, our leaders, after all, were only giving us what we wanted.

In a sense, the fuse of the bomb that exploded on Thursday was lit 18 months ago. That was when Trump, with bipartisan support, concluded a terrible troop-withdrawal deal that freed 5,000 Taliban terrorists and sapped the morale of our Afghan allies. Trump made scant provision to save Afghans who had fought with our troops. Olivia Troye, an aide to former vice president Mike Pence, has recounted how White House senior policy adviser Stephen Miller hindered every effort to bring the holders of Special Immigrant Visas to the United States.

Biden should have done better, but he didn’t. In April, also with bipartisan support, he announced that all U.S. forces would rapidly withdraw, along with the 17,000 contractors who kept the Afghan air force flying and the Afghan army supplied. Denied the ability to support their forces, the Afghan military rapidly collapsed in the face of a Taliban offensive.

Yet even as Biden was bowing out, he was ignoring calls from veterans’ groups to evacuate translators and other Afghan allies. Lawmakers, many with military backgrounds, pleaded with the administration to begin a mass evacuation, but their entreaties were ignored.

Why? At least three factors were at play. First, Biden was afraid of a xenophobic backlash from bringing so many Afghans to the United States. Second, he was concerned about sending a signal of no confidence in the Afghan government. And, third, he wagered that there was plenty of time to get people out later. But the Afghan government unraveled faster than anyone imagined, and desperate mobs of refugees swarmed the airport.

It was only then — with the Taliban already in control of Kabul — that Biden did what he should have done many months earlier: order a massive airlift of Afghans and U.S. citizens out of the country. What once could have been done in an orderly fashion with relatively low risk now became a highly perilous undertaking. The kind of “defense in depth” that was standard at U.S. military bases in Afghanistan — with multiple layers of trusted security personnel — was not possible in this chaotic environment.

U.S. troops were forced to rely on their enemies for outer-perimeter security. We do not know exactly how an Islamic State suicide bomber got close enough to carry out his devastating attack, but suffice it to say the Taliban guards were either incompetent or overwhelmed or simply unwilling to risk their own lives to save “infidels” and “traitors” from the wrath of fellow Islamists.

There are recriminations aplenty, but the sad fact is that the only way to avoid this particular disaster would have been either to stay in Afghanistan indefinitely or to leave our allies behind. Both options would have come with their own costs and were overwhelmingly rejected by the American people: Seventy percent of Americans wanted to withdraw from Afghanistan, and 81 percent wanted to evacuate translators and other allies. Our leaders were simply giving the American people what they thought we wanted.

The truth is that most Americans paid little attention to Afghanistan until recently (the three major television networks devoted a total of five minutes of evening news coverage to the country last year), and they had conflicting desires. They wanted out, but they did not want to bear the consequences of withdrawal. Those clashing impulses produced incoherent policymaking — and resulted in Sunday’s heartbreaking homecoming.