Kind of hard to put this feeling into words but I think it comes from a sort of helplessness in the world. A lack of significance, a lack of purpose, and a lack of efficacy in a person can take them somewhere really dark.
Is there anyone who doesn't know that feeling at all? Most of us find something at some point to take us out of it- religion, a hobby, a spouse, it's different for everyone but suppose a person didn't find this for year after year. Now all it takes is someone or something to blame.... and lord knows we've got no shortage of groups blaming other groups for all the ills in the world right now.
So then this person assigns himself a mission- a purpose to strike back at what he feels hurt him. A small number of these people manage to find the internal courage to go through with it and have their moment. Like it or not our society makes them more significant in those moments while they're an active shooter than they've been in their entire life. Even if you censor their name/photo from the news... which is nearly impossible it won't matter. He got his moment of power.
I don't think this is a new phenomenon. You can find examples of people melting down and committing mass murder throughout history. It does seem to be more frequent these days. I think it is because of our outlets- the things we find that give our life meaning are getting harder to come by.
Our society traps people by giving them nowhere to go. At least nowhere anyone would want to go. Religion may work for some but not all. Some folks find fulfilling lasting relationships, some kind find rewarding careers, some find close knit groups of friends... but all those things seem to be in short supply these days. IDK what the answer is but I feel like it could start with making our education and employment systems a little less... formulaic.