"The Trump administration in February 2020 negotiated a withdrawal agreement with the Taliban that excluded the Afghan government, freed 5,000 imprisoned Taliban soldiers and set a date certain of May 1, 2021, for the final withdrawal.
And the Trump administration kept to the pact, reducing U.S. troop levels from about 13,000 to 2,500, even though the Taliban continued to attack Afghan government forces and welcomed al-Qaeda terrorists into the Taliban leadership."
https://www.factcheck.org/2021/08/timeline-of-u-s-withdrawal-from-afghanistan/
To be fair, Biden is not without fault. However, he was trying make the best out of a situation that Trump created.
In fact, Trump bragged that he created the scenario:
June 26 — At a rally in Ohio, his first since leaving office, Trump boasts that Biden can’t stop the process he started to remove troops from Afghanistan, and acknowledges the Afghan government won’t last once U.S. troops leave.
“I started the process,” Trump says. “All the troops are coming back home. They [the Biden administration] couldn’t stop the process. 21 years is enough. Don’t we think? 21 years. They couldn’t stop the process. They wanted to, but it was very tough to stop the process when other things… It’s a shame. 21 years, by a government that wouldn’t last. The only way they last is if we’re there. What are we going to say? We’ll stay for another 21 years, then we’ll stay for another 50. The whole thing is ridiculous. … We’re bringing troops back home from Afghanistan.”