The Taliban offered to turn over Bin Laden for trial in any country other than the US weeks after the attacks [1][2]. If there reason to invade Afghanistan was solely to kill Bin Laden surely they'd just take the Taliban up on their offer.
[1] https://www.washingtonpost.com/archive/politics/2001/10/15/b...
[2] https://www.theguardian.com/world/2001/oct/17/afghanistan.te...