Not being a citizen of US and not being a follower of the religion of Islam (which I happen to respect like any other religion) I think this guy/ you did everything possible to freak out a customs officer. The reason I say this is you don't expect every custom official to have traveled the world and be aware of the actual culture. They only know what they have been told along with what they have heard, which is to say that they know nothing (unless each custom official has had a state department course on countries).
For a country that has been deeply scarred by a terrorist act all the officials know of is to look for some tell-tale sign of association. Those tell-tale signs as in your case may be completely bogus but they don't draw the distinction.
I agree the experience is bad and system doesn't see the difference.Let me point out that I don't support this behavior any more than you do but with the current situation I cannot blame them too.