Not to mention if a night in jail or fine (which itself is not warranted if the person is only mentally ill and not a danger to anyone or themselves), turns into a criminal charge that is then prosecuted and leads to a conviction, you've just made their path to rejoining society so much harder. Likely, their mental health predispositions will also be made much worse due to the strain of prison.
The system keeps trotting along because there's money to be made by prisons. People reflexively want the homeless off the streets and will tolerate, even reward heavy handed prosecutors. I've fallen in that category of punitive nearby residents - I live in a place near what has become a runaway encampment. When I drive by it and think how close my place is, I get angry at the homeless, the blight and trash. I have to force myself to think of the humanity, the suffering and lack of options these folks have. But to be honest, other than try to support local action to help these people, I don't do much either. I take pride in not joining the rest of the NIMBYs but you wouldn't believe the shit fit people around here threw because mobile showers were coming to the encampment once a week. Some of the people who threw the biggest shit fit also have political yard signs supporting anti-poverty measures, but as they say, talk is cheap; yard sign, sure - build cheap community housing near me or allow people to camp - hold your horses...