I'm sure the particular circumstances of this latest horror will come out in the next few days. But in general, kids going through school sometimes suffer isolation, bullying, trauma and resentment that the idealised life they see on the tv is different to theirs. They may project their disappointment onto their teachers.
Not many places though where those detached from society have easy enough access to the firepower to kill over a dozen people. mainly children, before being put out of their selfish misery.