Ransom can mean two things:
If people talk about that they need to pay money to the state or the police, to get free, the correct legal term used is usually bail.
Often in piracy, pirates would steal something or someone important and demand a ransom payment.