If people are innocent until proven guilty, why can they be held in prison until they’re actually convicted?

Maybe this is a stupid question but it kind of confuses me.