The modern world is set up in such a way that it's far more common for people to 'snap.' The country's mental health problems are so embedded into our ways of life. Add in someone's inherent racism, political radicalism and religious zealots and well, it's an epidemic.
For the loner types who have no goal or agenda other than inciting terror, it's a lack of sex that makes them so angry and bitter. That primal urge and subsequent failures with women/men sexually is a main ingredient in these acts.
I wish we could drastically avoid commonality of these tragedies but Pandora's Box has been opened- there are too many guns in circulation - a black market would thrive and the wrong people would be more likely to seek them out.
Hopefully, they can devise some legislation that quells the problem without impeding on people's right to fully defend their home and family.