Hilary Putnam has an excellent chapter called "Materialism and Relativism" in his book Renewing Philosophy. In that chapter, he analyzes how what we identify as "the" cause of some of it is dependent on what we are interested in at the time.
He gives the example of explaining a man's heart attack. We could say his heart attack was caused by:
1) his shoveling snow
2) his genetics
3) his high blood pressure
4) his failure to follow his doctor's orders
And more. And all of these explanations can be correct, and none of them contradict the others. If we want better screening for potential heart attack victims, we may want to focus on number two. If our interest is in cautioning people to take it easy after the upcoming blizzard, we might focus on number one. Interest is in getting people to pay attention to their doctor, we might focus on number four.
And so explaining a terrorist attack: easy access to guns, radical Islamist ideology, the hatred in a man's heart, insufficient screening of immigrants, and aggressive American foreign-policy can all be explanations for some attack, depending on our interest when we are doing the explaining.
The only truly complete explanation for any event is the entire state of the universe before that event occurred. (E.g., if the sun had gone supernova earlier this year, the Orlando massacre would not have occurred.) When we pick out some particular feature of that entire state, we do so because of some particular motive.