My assumption is for every one of these attacks, the attackers do not consider their actions to be irrational. They believe what they are doing is the right thing. Either for religious or political reasons they are the good guys in whatever war they are fighting. We think of the Germans and Japanese in WWII as the bad guys, but they were fighting for their country. They were patriots. From their point of view they were fighting against the bad guys (us).
As long as we look from the outside in (from our point of view), we'll never see what they see. Their actions are completely rational to them from their point of view. They are defending their way of life. They cannot stand against us directly so they lurk in the shadows and strike when they have the opportunity. We did the same in the American Revolution. We violated the rules of honorable warfare by targeting officers and by not going toe to toe with the British solders.
By no means do I condone their tactics. I am revolted by these attacks. But to look at the overall climate only from our point of view will guarantee these attacks will continue, and they will only get worse.