I get asked this question a lot, normally around a glass (or bottle) of rose wine in the pub. Acts of terrorism (although I am not convinced we should elevate their social status anymore than we have to) are almost always impossible to comprehend. The act will normally involve mass murder, multiple indiscriminately selected victims of any age or sex and will come without warning. The IRA at least operated from a code of practice or "The Green Book" as it was. Although not every time did they warn people I admit but I guess at least the thought was there.
The biggest problem is the media. Several news agencies referred to the incident as an Islamist Attack" - now should we be referring to the extreme right wing as "Christian Fundamentalists?" and by the way some do. Why should law abiding religious folk have to carry the can for those that are simply looking for an excuse? Most people need to understand why things happen and when we can't, the simple answer is "they must be mad".
The real answer is not as simple. In almost all cases (I studied terrorism at the University of East London) these people are very sane, very intelligent and as was the case of early Al Qaeda, from good social status and normally of university graduate level. The problem lies within society and its understanding of the history between different cultures and religions.
Early intervention methods in schools and community cohesion is the answer. The community that these terrorists are from are normally the first to notice if something is going wrong and they need to be able to trust the authorities and other communities to help them and report such matters. Of course you will always have the one or two exceptions, Nicky Riley in Exeter is one such example. He self radicalised in his bedroom and used the internet, another problem of mine.
The reactions from every one of us will now dictate what happens next. People are angry and will want retribution but the key is to understand the history of conflict before taking that retribution out on innocent members of Islam. Anger and the desire for revenge is one of the most dangerous emotions we have. If not constrained it will lead to a host of new problems that will fuel a surge in right wing / religious hatred. Like Christianity and many other religions there are always those who misunderstood or choose to simply take the bits out of it they want to and create a morale defence in order to do unspeakable actions.
99.9% of Muslims are good law abiding people. The media will of course only focus on the few that step outside the boundaries of Islam and paint a picture that not reflective of its wider community.