For true "mass-shooters" -- typically young males who get a gun (maybe an AR, AK, or maybe just a pistol) and go to a public place in someway associated with their failure in life, and shoot up the place, with little regard to what happens to themselves -- the answer might lie in their brain chemistry.
Many of these young males have been sedated or tranquilized throughout their school years by psychotropic drugs, administered to make them easier to handle. It is well known that these drugs change the brain's chemistry, and stopping taking them, or taking them intermittently, can cause a suicidal impulse in some people -- and sometimes, a murderous impulse.
These young men, the mass-shooters, are typically from single-parent families and after high school they just drift along, living in a crummy apartment or someone's garage, failing at everything they attempt, and presumably NOT taking their meds on a regular basis. All of that, plus the factors mentioned above -- a school system that passed them along rather than teaching them anything, a giant void in their lives filled by computer games (typically about shooting people), and vague discontent and alienation from either the extreme left or right wing via social media -- and a small number end up choosing to shoot a bunch of people.
Young men who have discipline problems or learning problems in school should be given more attention by teachers who can relate to them and act as positive role models, more phys ed, more specialized training in a trade or outside occupation (e.g., not more classes designed to prepare them for college), a limited diet of computer time (how about 1 hour a day?), and maybe a lot fewer psychotropic drugs. When they graduate from school their meds should be monitored and deliberately tapered off -- the shrinks who administer these things are responsible for these outcomes and should stay in the game until the kid reaches some form of maturity. These kids should have a shot at a decent job, too -- I don't know how that would work, but if I faced a future life of working in fast-food restaurants I might give up hope too.
There are a lot of kids like this and only a few turn out to be mass shooters - a larger number kill themselves, though, directly or indirectly.