What mental issue specifically? Example, Childhood mental trauma caused psychological issues that made the convict a violent criminal,would that be better dealt with by a psychiatrist than prison? Probably,but the purpose of prison isn't correction. Correction is a desired end goal,but regardless of correction,prison is punishment for a person that broke the rules defined by society. The line is drawn somewhat clearly: if you are able to understand the ruled and apply reason to your decisions,you are held responsible for the consequence.
IMO, free psychotherapy in prisons and getting rid of private prisons is a good idea. There is too much of "this is how we've always done it".
I am also more concerned about the 90something% of cases that end up in a conviction due to plea bargaining. No due process. Tons of possibly innocent people admit guilt to avoid having their day in court. Risk getting a false conviction and serve 10yrs or plea bargain and get just a year,what poor person would take that risk if you can't afford a good lawyer?