A mistrial can be declared for a bunch of different reasons, like if a juror is found to be biased or if new evidence comes to light that changes everything. It's like hitting the reset button - everything starts all over again from scratch. The good news (or bad news, depending on how you look at it) is that the defendant doesn't get to walk away from the charges just because the trial was a bit of a disaster.
Now, you might be thinking, "But wait, isn't double jeopardy a thing? You know, where you can't be tried twice for the same crime?" And you're right, it is a thing - but it doesn't apply in the case of a mistrial. The idea behind double jeopardy is to protect people from being harassed by the government, but in the case of a mistrial, it's more like a "oops, let's try that again" situation.
In fact, did you know that the concept of double jeopardy dates all the way back to ancient Greece and Rome? It's been around for thousands of years, and it's still an important part of our justice system today. But, as we've established, it's not a "get out of jail free" card - if a mistrial is declared, the prosecutors can still come after you with the same charges.