Yes.
This is one of those questions that seems philosophically interesting but is not interesting pragmatically.
When you jail someone, you have reason to believe they are proximate to what you believe is a crime. You remove their freedom to move/act temporarily while you ascertain the existence/severity of a crime, and if they are a party to that crime.
When you figure out that you made a mistake, you release them.
"...and then you give them a sizable bank deposit for all of their legal costs, not justice served the towing of their car, the income they were unable to earn while jailed, the job they quite likely got fired from due to missing work, the ruination of their reputation, the destruction of their family, the diseases/injuries that occur while they are in jail, the mental damages, the spoiled food in their fridge, the bills that go unpaid, the overdrawn checking account fees, the credit card APR that jumps to 29% due to a missed payment, and the plea deal they finally agree to - despite being innocent - because the DA uses the full force of government power to leverage all of the above, making it rational to take a plea rather than spend 2+ years fighting it with income you no longer have, right?
...RIGHT???"
AnakinAmidalaMeme.gif
Your simplification of this scenario - which is playing out millions of times every week in the USA across thousands of criminal courts - as a simple mistake that can just be un-done, is one of those perspectives that "seems philosophically interesting but is not interesting pragmatically" because the system does not operate in that philosophically ideal way for anyone.