The taliban had a peace contract with the USA and slowly started taking over cities in Afghanistan as the US armies departed. They said they weren’t going to “take over Kabul” but the government was falling apart so they had to step in is what I have gathered from my knowledge.