Sometimes people pay a very high price for those mistakes. Even more rarely, someone is exonerated and compensated for those mistakes. This has just happened in California where Kenneth March received $756,900 of compensation for wrongful imprisonment from the state. He was convicted of second degree murder in the death of his girlfriend's two year old son, but it turns out that the death was largely caused by medical malpractice following an accidental injury. The state legislature still has to approve the payment in order for him to receive it.
If the case has been charged as capital murder, he might have been executed by now. As in many wrongful conviction cases, the problem was not a major procedural failure in the court system, it was the failure of his counsel to do a sufficient factual investigation in advance of his trial to discover the facts that would later exonerate him. Yet, habeas corpus law is especially hostile to claims of actual innocence, largely limiting itself to vindicating procedural mistakes in the state courts, and imposing ridiculously intricate procedural requirements of its own on largely self-represented prisoners.