Car thieves don't steal cars while in prison. Bank robbers don't rob banks while in prison. Some crime may continue within the walls of the prison, but the world outside is protected. If a person would commit crimes for 40 years, keeping that person in prison for 20 years is a 50% crime reduction.
There are other ways to confine people then prisons. E.g. you can place people under house arrest, curfew, etc.
Also your logic if flawed. Confining people after the deed seem logically a really poor and inefficient way to reduce crime. While one criminal is confined, there will always be another. So your 50% crime reduction is closer to 0%.
So our best theory of behavioral modification states that prisons is not a deterrent for crime, nor is there any evidence for it in the records. All the while prisons are an inhumane and terrible way to treat people. Can we just please abolish prisons.