Even if you are 'not guilty', you're still getting punished, and that's a clear sign of being held culpable.
What is punishment and what is treatment? That is the rub. Obviously, you can not have a person lacking the ability to discern right from wrong running free in society, especially when they have already harmed others (or themselves) because of this ailment. Also, you can not punish them because they are not culpable for their actions.
Treatment is treatment. It is an attempt to cure the person of their psychosis. If I remember correctly, Brinkley (attacked Reagan) may be let loose in the near future. Doctors consider him cured of the psychosis that caused him to attack Reagan. People are put in this same type of treatment even if they have not committed any crimes. If the judge deems that a person is a threat to themselves or others then they can be put into mandatory treatment.