You can be mentally ill and still be criminally responsible.
In a lot of countries, it depends on how much money you can pay and what friends you have. In the US, it depends on how much money you have to pay for your defense, if you belong to a religious group with political ties, if it is a high profile case, who the victim is, and other factors. It is not about whether it is a fact that you are mentally sick, it has to be shown that you do not know right from wrong or did not know right from wrong when committing the crime. A big issue I have been reading about in the news is how many crazy people are thrown in jail with everybody else.