I asked this a couple years ago but everyone wanted to focus on guns instead of the mental health issues which are obviously the underlying problem. Guns just make it easier. I believe the problem is mental health, but not necessarily a diagnosed mental illness, but instead a culture which breeds mental issues. Some of these have been touched on above with respect to accountability.
The primary issue with mental health deficiencies I believe is cultural and the second is true mental deficiency/illness.
I think single parent/two-parent working households presents an enormous problem. We are bombarded with everything we HAVE to have and in order to have those things, one of the sacrifices is for both parents to work. In the case of single parents, there isn't an option, they are the sole breadwinner. Not only are parents not parenting and teaching kids respect and caring for others, personal responsibility, and a sense of morality, they just aren't present. They are working. And when they are there, they are more focused on themselves than on the sacrifice it takes to actually raise kids properly. I'm not immune to this, nobody is. But there are different levels and I think there is a healthy balance of taking care of oneself and the responsibility that comes with raising kids. But the US leads the world in consumerism and image by a large margin and I think that has created a culture of judging people by what they have and not who they are/what type of person they are. This lack of parenting also leads to the lack of accountability issues others have talked about because either consciously or subconsciously, the parents realize they are absent to some degree and don't want to risk further alienating their kids, so they always side with them, never punish, always reinforce that the kid is right. This isn't parenting.
Secondly is social media. Too many people in this world (and especially this country) are focused on "me" instead of "us". Everyone can be a star or the perfect family or live the perfect life on Facebook/Insta/TikTok and these outlets create a false sense of reality for people who see themselves as NOT having the same stuff/life/experience/happiness as everyone they see on social media. It breeds discontent and depression and a sense of loneliness and lack of caring for others. The only way to reach out and develop relationships is online with other people who have similar experiences and harbor the same feelings and it spirals downward from there. We see this clearly with Politics - people's world view shrinks because they are force fed more content that supports their world view and demonizes any other viewpoints. Again, this is rooted in the rampant consumerism and the need to HAVE things and be LIKED which is fostered by our material/marketing culture more in the US than anywhere else in the world.
Third is true mental illness. Some people just have their wires crossed and should be treated but are not. That's an entirely different conversation, but it is something that needs to be addressed.
For those who don't have a moral compass to help guide them, (from not being raised to have this moral compass) they lose a sense of right/wrong and instead focus on the unfairness of the Haves/Have Nots they see playing out on their Twitter/Insta accounts. They eventually depersonalize the Haves and feel justified in killing these people.
My $0.02.