I know it probably comes from a good place but I genuinely think you borders on the dangerously extremist on this one. I reckon that society has failed the majority of people who end up in prison and that a better society with better education, healthcare and welfare support will eradicate most problems. That’s towards what the Scandinavian model is getting at.
Your suggestion that even after that support was provided someone could rape someone else and then society would just say “well, that’s a case for the hospital then” to the victim and let the criminal walk free is even worse than what we have now and pretty distasteful tbh.