the 9/11 attacks on New York were carried out by al-Qaeda, who were indeed based in Afghanistan and supported by the Taliban, who were the Afghan rulers at the time. (The actual attackers were mostly Saudi extremists, like bin Laden.) The attack wasn't much to do with oil at the time, it was to overthrow the Taliban, root out al-Qaeda and in effect to get revenge for 9/11.
It seemed to go easily, which I suppose is why they decided to launch an attack on Iraq as well - and that, I think, was about oil. But two wars at a time overstretched them (and us) and we're on the way to losing both of them, I think, and leaving the Middle East/South Asia in a bigger mess than we found it.