Answer:
Of course. If the US had not invaded Iraq and Afghanistan, 9/11 would have never occurred. Wait, that doesn't make sense, does it?
Okay, so the war on terror is clearly not the cause of all attacks on the US and its allies.
That isn't to say the terrorism is caused by a couple psychopaths with no grievances. While many terrorist leaders (at least the ones I've seen in the news) are definitely psychopaths or something close, they rely on a large group of what in a better world would have been normal people.
So why do those people attack us? Well, probably for a thousand reasons. Let's not forget that western countries (and the US in the last 65 years or so) have caused a lot of problems in those countries. Sometimes, we wanted to support our ally Israel. Sometimes, we were worried about the spread of communism. Sometimes, it was western psychopaths (we have a couple too) just being greedy. Let's also not forget a lot of these people are probably living pretty stressful lives and are getting some really bad advice (see psychopaths).
Step-by-step explanation: