These are random acts. I don’t know if such acts are indeed becoming more common vs. the past - perhaps only the media coverage is increasing.
Trying to “prevent” such random, and rare, occurrence, is like trying to prevent lightening.
There was a link to a story on Drudge earlier (I think it was Drudge) from the AP indicating that statistically, mass murders are down of late compared to history.