Looks to me like a fine educational experience
Whack a cop with a baseball bat (even a "crude" one) get shot. Die as a result of getting shot, lesson permanently learned.
As reported, there was no altercation, the kid (6' 250lb who was bigger than the cop) came up behind him, and hit him in the head with the bat. Gets shot while winding up for the "home run".
Cop's "clip" came out. Two possibilities, one) magazine was not properly seated and locked in (unlikely). Two) Dazed from a baseball bat to the head, officer accidentally hits mag release when grabbing for his pistol (likely).
Officer has enough presence of mind to go for back up gun, uses it effectively. Threat canceled, no bystanders injured.
So, all we are left with is the intellectual curiosity as to why this 17 year old student attacked the officer, apparently without warning and without provocation (if further reporting changes these facts, we will revisit our opinion). Was he mentally ill? Was he delusional due to drugs? Was he depressed, and this was a case of suicide by cop? Did he mistake the officer for someone else (who he intended to hit in the head with a baseball bat)? Did he just do it for fun, never realizing that the cop might actually defend himself with deadly force? Did he not know that hitting someone in the head with a bat is considered an unfriendly act?
All these questions (and more as well) will be asked by someone(s), over and over for some time. While the why could help explain it, and knowing why (if we ever do) might help prevent someone else from doing it, it really isn't the important lesson. I don't think the shrinks will focus on it as they counsel the students, but to me the important lesson here is "he did what he did, and he got what he got". Don't want to get what he got? Don't do what he did! How much simpler can it be?