I take it that a Mentally insane person would just grab a gun at whim and start to shoot. This guy had a CLEAN record and no signs of any mental illness.
You are comparing the definition of mental illness with the legal definition of insanity. Realize that depression, anxiety, OCD, bipolar illness and BPI with psychotic features, scizophrenia and more are illnesses that affect perception of reality to varying degrees. People function at different levels when they are mentally ill. If you've ever watched a person slowly descend into madness, it's not an okay one day and completely crazy the next kind of thing. Delusional thinking can creep in insidiously. The changes can be so gradual that the loved ones and friends just think the person is becoming gradually more difficult in personality. This shooter is being described as unstable. The pressures and rigors of the courses he was taking could be a big part of why he snapped.