When someone is suspected of a crime, they are often imprisoned leading up to their trial.
... after a judicial hearing in which bail is denied. People are not just locked up - most countries have very stringent rules as to how long you can keep somebody without a hearing - typically 24-72 hours, though "terror" legislation has eroded that in some countries.