Based on what previous school shooters have said over the years, the reasoning is somewhat simple and obvious. They experience trauma at a particular time in their life, and once they've mentally broke, the most personally "relevant" target for their anger is a group of people similar to those who either caused the original trauma or were present at the time but "did nothing to help." It doesn't matter that they're not the exact same people, because it's very rarely about revenge against specific individuals, but instead a way to exert control over a situation or space that they associate with their earlier trauma.
https://www.gq-magazine.co.uk/article/mass-shootings-in-amer...