In the US, sentences are mandatory of many crimes. This means if the prosecutor accuses you of a crime carrying 25 years, the judge cannot take any other factors into account - he must jail you for 25 years.
The only 'out' is to help incriminate other people. If a police officer forces or tricks someone into committing a crime, thats entrapment and the case is thrown out. If the police officer forces someone else to entrap a 3rd person - thats ok.
The story of John Horner is very interesting. He was talked into sharing prescription drugs with a friend who couldn't afford them - and was then arrested for drug dealing. The friend had, it turned out, been arrested and threatened with 25 years unless he incriminated others. John was offered the same deal. Find 5 more people who can be arrested for drugs offences and see your sentence reduced.
BBC News - The trouble with using police informants in the US
Then there is the case of 23 year old Rachel Hoffman who was arrested, threatened with 5 years in jail, and then sent out on the street with a wire and no training and a mission to track down drug dealers. She was dead a few hours later - murdered by a drug dealer who quickly found the wire.Under the deal he signed with prosecutors, he agreed to plead guilty. But if he helped make prosecutable cases against five other people on drug-trafficking charges - charges carrying 25-year minimum terms - his own sentence could be reduced from 25 years to 10.
That choice - put crudely, do the time or snitch - is one faced by thousands of Americans every year.
Mad system - hopefully it will never arrive on these shores. But it explains part of how the US manages to jail 1% of its entire population.