The core issue is that outside Kabul and a handful of other spots not much has really changed on the ground between 2001 and 2021.
Yes, people weren't being starved to death wholesale anymore, but that's mostly it.
There were some, very small, improvements to the infrastructure, a couple of doctors would show up here and there once in a blue moon, but beyond that outside the major urban centers and provincial capitals the government (or Western forces) had no real day to day presence. Tribal councils and the Taliban ruled and now and then a occupation patrol would show up briefly, hand out some "aid", maybe install some solar panels, a couple of water pumps or whatnot and shoot/arrest any Taliban in a pinch. Then they wouldn't show up again for weeks or months, maybe drone strike a wedding or two.
This wasn't per say the "failure" of the Afghan government, this was a failure of installing a government made up mostly of former warlords who represented pretty much nobody outside their specific little bandit group/tribe.
Afghanistan is not a fucking country as we understand a country. It's a geographical area populated by a collection of distinct tribes/ethnic groups who often hate each other or speak different languages and who pretty much recognize no authority beyond their tribal council. This is something the Taliban seems to have understood. While they extort "taxes" (protection money) from the tribal councils and impose certain rules (mostly via controlling the road network, border crossings and urban centers), they don't actually really bother with governing because they are perfectly aware that the country is practically impossible to govern.