It makes sense that people would make such an assumption: we can't imagine how anyone could commit such acts, so we assume there must be something very wrong with those who do. However, is there evidence to support this assumption?
According to a National Institutes of Justice report, past research shows that only about 3% of violent crime can be attributed to mental illness; instead, demographics such as age and gender are better predictors of who perpetrates violence. Indeed, instead of perpetrating crimes, individuals with mental illnesses are much more likely to be victims of crime.
When individuals with mental illnesses were found to be perpetrators of violent crime, the severity their current psychotic symptoms was a factor, rather than their diagnosis, or the presence of mental illness more generally. Specifically, certain kinds of delusion, and substance abuse, seem to be associated with greater risk of violence. The specific delusions that are most likely to lead to violent behavior are delusions of persecution (believing others want to hurt you), thought insertion (believing an outside force is planting thoughts into your mind), and delusions of control (believing an outside force is controlling your thoughts/feelings/actions).
I don't know about you, but I can understand how someone experiencing these kinds of delusions may feel like violence is necessary to their self-preservation. I can also understand how such delusions may lead someone to commit suicide after violent behavior: they may feel like the only way to stop the outside force from inserting thoughts, controlling, and/or harming them is through death - particularly if the symptoms are not alleviated by the violence (which seems likely); alternately, they may have some insight into what they've done and feel unable to live with that knowledge.
Community-based mental health services may help to prevent the severity of psychosis that may trigger violence, by encouraging treatment/medication compliance, monitoring mental status, and intervening when delusions appear. However, people are also more likely to begin refusing treatment and medication, and may withdraw from services, when psychotic symptoms occur. As a society, we highly value personal freedom and self-determination; it is very hard and very messy to attempt to infringe upon anyone's freedom - as it should be. It also becomes challenging to provide for the safety of community-based mental health workers when clients are actively psychotic or substance abusing.
While questions about the mental health system are important, it's also important not to scapegoat individuals with mental illness, when the majority of violent crime is not associated with mental illness. Instead, attention should be paid to identifying and responding to the other 97% of violent crime.