In Brazil there's what we call "preventive custody". If you're caught committing a crime, and if there is a risk that you could jeopardize the investigations (by eliminating evidence, threatening or influencing witnesses, etc.), then you are held in custody until the investigation is concluded.
I don't believe you would find something very different going on in any other democratic country.