Pirates would be treated as criminals, and assumed to be innocent until proven guilty, unless they were caught in the act of hostile action against the US, and that would not apply to figting the US in Afghanistan. The US was not at war with Afghanistan.
Al Qaeda was not the Taliban, they were a foreign organization given sanctuary by the Taliban, which was the closest thing to a government that Afghanistan had at the time.
The Taliban was given an ultimatum to turn over the Al Qaeda to the US, and they did not or could do this, and Afghanistan was invaded.