I believe you nailed the true root cause. District attorneys have the power to choose who to charge and to what degree. It is not a DA's responsibility to weigh what is for the good of society, they need only to be concerned with conviction rates. Does that seem like the foundation for justice?
I think you've nailed the true root cause. There isn't someone elected to be on the other side of the DA, like a public defender's office whose goal it is to get accused criminals exonerated. If one political party wants both seats, they'll both have to make each other's job hard.
They can't, if you're a Judge and you cross the prosecutor too many times they will stop bringing cases to your court and you will find yourself judge of traffic court instead of criminal court. Prosecutor essentially get to pick the judges this way.
Unfortunately, in the US judges are elected, and the usual platform is "tough on crime". They have a metric they are optimizing for, and it's a suboptimal one.