If you have a dog, it can be a perfectly well-behaved dog. But then you lock it up in a room all day and, out of boredom, it will still end up destroying a bunch of stuff. Clearly we know that it knows better, since the rest of the time it behaves well. Thus we must assume that something else overrode the higher cognitive reasoning of the dog.
Similarly, if you leave a human alone in a room, with no human contact we know that he’ll go insane. Rationally, he may well know that there’s no value in fidgeting, in flinging poo, etc. But he’ll still end up doing it, no matter who he is, because our underlying systems can take precedence over cold logic under certain circumstances.
If you’re of the belief that prison is better suited as a rehabilitative measure, rather than a punitive, then likely you would agree that punishing a dog that misbehaved - after being locked in a room all day - is going to have no effect. You would say that you need to let the dog out and walk him. And I think you would say that because you would think that it’s reasonable that the reason a criminal misbehaved was because he didn’t have other options in life, he had been pushed in a wrong direction by peers, etc. Punishing him doesn’t correct any of that. It makes more sense to track down the causes and figure out solutions than to leave those in place and punish him for something that may well be very little of his own doing.
But so, if someone is depressive, schizophrenic, hyperactive, or whatever, then basically we’re just saying that for this person, their ability to operate based on their higher rationality is diminished. Slapping 'em and telling them to change their behavior is unlikely to be effective. We have decent reason to believe that mother nature is not fair. People are born with all manner of deformities and afflictions. And we know that those afflictions aren’t nicely binary. You aren’t “20/20 vision” OR “blind”. You’re likely somewhere on a continuum. Likewise, you aren’t “schizophrenic” or “sane”. We’re all somewhere on a continuum, and the medical delineation between the two is arbitrary.
In an ideal world, we could apply genetic manipulation to remove afflictions. But we do not yet live in that world (and many people seem to think it would be a scary, awful place). Nor do we have the medical ability to resolve these afflictions by modifying the body chemistry of those who are afflicted without side effects. We don’t have good ways to test for mental afflictions, to prove that they are due to physical causes, to test the exact percentile that the person is afflicted by, nor target it with the perfect medication.
So overall, we are left with imperfect solutions being applied as stabs in the dark. For some people, that will mean that they are being over-medicated. For others, it will mean that they are under-medicated or wrongly medicated. On average, where we stand is anyone guess. We would need the technology that allowed us to medicate better before we could tell how far off we currently are. Today is not that day.