I don't say this as any sort of moral or character judgment, but simply to point out that part of the reason this thing is allowed to happen is because the people it's happening to are very rarely sympathetic individuals. They're viewed as bad people and "others" by the majority of the population.
So what's the fix for this? I wish I had an answer, but I don't. Maybe teaching empathy so that the court system starts feeling pressure from the citizens that this isn't ok. Maybe legislation against charge stacking just to elicit plea deals. There's also the very real possibility of the pendulum swinging too far in the other direction where DAs don't charge petty crime and people charged with violent crimes are released on signature bonds.