My comment as a student of criminology and sociology is that your question is very complex and it sort of hinges on the social determinants of both mental illness and crime, which are very related. Poverty, marginalization as such, living in impoverished neighbourhoods, and those sorts of things are related to both of those problems.
But going back to your question about increasing recidivism because of the lack of mental health services in correctional settings—if I could paraphrase it—not providing people with mental health and substance abuse treatment is detrimental to their participation in correctional programs that are focused on reducing those sorts of things you talk about.
We know that by providing people with mental health treatment they're able to better participate in the programs that are specifically designed for recidivism in correctional settings.