Historical speaking, the British system of law dates back to the Magna Carta and is designed to prevent abuse of power by the King / State Government. Think of the Red Queen from Alice in Wonderland shouting "off with his head" against anybody who displeased her in the slightest.
The social contract permits the King / State Government to retain their monopoly on violence, but under the restriction that the State is only permitted to use it in accordance to both the rule of law and the consent of its citizens.
For the King/State to legally use violence/imprisonment against you:
- The King's/State's Police may arrest you temporarily
- You have the right of Habeas Corpus, the right to a trial
- You are assumed in law innocent until proven guilty
- The King/State must prove your guilt beyond reasonable doubt
- The Judge is a servant of the King, thus can only judge the King's law but NOT guilt/innocence.
- The verdict (and your fate) is decided by a jury of 12 of your citizen peers
- The jury deliberates the case in the Jury room, without the Judge
- The jury is forbidden from explaining its decision
- Implicit in this is the right of Jury Nullification (refusing to convict against an unjust law)
- It is only with the unanimous consent of your peers that the King/State/Judge can legally pass sentence
In the US, this conceptual framework is encoded in the Bill of Rights, especially the 5th, 6th, 7th and 8th Amendments.
"The real culprit bursts into the middle of a trial and confesses"
If the jury has already concluded a verdict, then the Judge would most likely:
- suspend the current trial (pending a new verdict)
- order the arrest and full trial of the new "confessor"
- keep the originally accused imprisoned/on-bail (it could all be a ruse)
- wait until a jury has passed "guilty" verdict on the "confessor" before passing sentence
- accept the defence motion requesting a retrial of the original case
However, if the situation was reversed, and the jury has just passed a not-guilty verdict on the "defendant" who suddenly confesses before sentencing, then there is the slightly complicated issue of Double Jeopardy. In theory, this prevents a person from being tried twice for the same crime, so all you need is one not-guilty verdict to get off scot-free. However, in practice, lots of countries have various "exceptions" to this rule for situations just like this.