One is put in jail after an arrest before trial. They require a fee to be released before trial. Even if one is acquitted of charges, they do not receive refund.
No, actually not. The police can place you in arrest, but only for a limited time. Then a judge has to decide based on various factors whether you can be kept in jail until trial, whether you can get out on bail and how large the sum is, and sure, you get the bail money back if you show up in court, even if your not acquitted. [1] The important factor is that a _judge_ gets to decide that, not a prosecutor or mere policeman.
[1] Please note that if you loaned the money from a bail bondsman, the bondsman gets to keep his fees. This however is a separate transaction.