This wikipedia article shows that Taliban still control a significant portion of Afghanistan. How are they doing it and and what has the government/US done about it?
I am an Afghan national and I have worked 6 years with US Army Marines, British Army and private contractors. The truth is that our government is corrupt and no soldier is going to die for 200$ a month for a corrupt government.
The second reason is NATO leaving Afghanistan. At the beginning there were almost 150,000 soldiers from different country now there are only about 14,000. They mostly stay in camp and do not fight. The Taliban are on the offensive against weak Army with no morale with corrupt leader.
There are a lot more reasons why Taliban are gaining more.
When civilians are killed by Americans and NATO, the Taliban use it as propaganda to gain more support from the local villagers.
The Vice documentary "This is what winning looks like" might give you a few helpful pointers:
It lays bare the unfortunate inadequacy and corruption of Afghan troops, their low discipline, and their lack of support within the population in the countryside.
The takeaway and answer to your question might best be summed up by the documentary's author:
All it is now is about getting out and saving face. We're [U.S. forces] not leaving because we achieved our goals. We're leaving because we've given up on achieving those goals.
Put another way some parts of Afghanistan never were under control to begin with; the Afghan troops that are fighting the Taliban are - if only at times - poorly trained, undisciplined, and corrupt; and the US is basically drained of any motivation to help. (See for instance 1:17:00 in the video for an arresting account of how the US' financial aid was being wasted.)
we down sized our armed forces and so did nato. the afghanistan army could not hold there own, so the taliban over ran the areas. same with the iraqi army they could not hold there own. both countrys army could not hold there own in battle and ran leaving all these combat supplies to use against them another day. our soldiers payed with there life for these countries to run from battle. loner