I'm of the opinion that Iraq doomed Afghanistan. It sucked away so much resources. Afghanistan went from "must win" to keep the bench warm. Imagine a world where Iraq 2003 didn't happen, and how the Afghanistan war would have run and what resources would have been put in to reform and rebuild Afghanistan. And what would have been done to hold Pakistan to account.
Instead, resources got split and the US presented all kinds of targets of opportunity to Iran on both borders and enabled Pakistani duplicity as we became reliant on them.