The U.S. didn't tell the Afghan when they were leaving. Again, part of the problem. The U.S. had already removed all unprotected high grade equipment. I'm sure there were many in the Pentagon who told Biden behind closed doors they had to leave without notice to get everything out, which they did.
My guess, and I'm just speculating, is the U.S. had made a secret deal with the Taliban for them not to enter Kabul. The Taliban then asked for money, the U.S. said no, so they entered the city.
Now the U.S. can't renter the city because they'd have to fight door to door which would be a civilian bloodbath of unspeakable dimensions.