The story told, in Muslim communities and schools, is a very simple one but one that is effective in eliciting strong emotion. It goes like this:
Hold Allah and his prophet dear and forget about life in this world for life in paradise is so much better, so much sweeter than here. This earth is temporary. But what you do in this earth will decide on the day of judgment whether you go to paradise or hell. And as our prophet said there is no guarantee that you would go to paradise but if you fight for the cause of Islam and for the cause of Allah.
Let us all follow the example of Muhammad Sal-Allah-o-Aleyhe-Wa-Aleh-i-Wasalam and forget the devices of shaytan in this world for if we do so we will be victorious both in this world and the judgment day."
This last part is what solidifies it in one's brain that in the end all that matters is doing the bidding of Allah. Because if you disobey him, not only are you going to pay dearly (by getting murdered, raped or tortured somehow) in this world but also in the hereafter.
Now if you were Muslim, wouldn't this story resonate with you? It did with me, for a very long time.
And not everyone who then goes on and blows someone up or kills an innocent person does it out of a "pure heart for Allah". Many are already criminally disposed but this gives them the justification they need. And in the end, what does it matter anyway? They are told to follow Mohammed, and Mohammed himself was a criminal, a bandit.
Many a times Muslims who carry out attacks against innocent people do hold on to just one or two verses from the Quran and a couple of stories from the Hadiths but that is not a sporadic thing. It is a long process of education.