Puberty can be a trigger for a number of mental health disorders, often it's in the teen years that people are diagnosed with schizophrenia or bipolar, both of which can be accompanied by psychosis.
We really have no way of knowing at the moment what caused him to take the action he took, but it seems unlikely that he's a well rounded, mentally healthy, well-supported boy.
He's a 17 year old boy, his actions and the results were horrific but I strongly believe that when police are investigating his life and the circumstances of what he did and why they will find that all was not well.