The mission was to seek out those responsible for the events of 9/11 and bring them to justice. The Taliban had nothing to do with 9/11, but they were friendly towards those responsible. They offered to cooperate and even assist, provided the US proved their accusations had merit.
Taliban 'will try Bin Laden if US provides evidence' | World news | guardian.co.uk
The US responded to that offer with bombs.
We should have anticipated having to deal with POWs when we went into a war zone to fight. Personally I would have supported dropping off our POWs in a remote corner of Northern Canada with enough tools and materials to build a suitable shelter. Give them a heads up about Canada's winters and suggest they get busy.