!!! Analogy Warning !!!
Bob is heroin dealer, who is attacked by an armed robber while walking down a dark alley. Bob shoots and kills the robber. The cops have been following Bob because they suspect he's a heroin dealer, and they witness the shooting. The cops snag Bob up after he kills the robber, and take him in for interrogation. During the interrogation, they tell him that he's under suspicion for being a heroin dealer, which carries a sentence of 25 years... but that murder only carries a sentence of 5 years. Bob isn't completely sure how much info the cops have on him with respect to heroin dealing. The cops offer him a deal: plead guilty to murder and flip on his supplier, and they'll drop the case against him related to heroin dealing. The cops tell Bob that if he doesn't take the plea bargain, they will prosecute for heroin dealing.
Bob didn't commit murder - it was clearly self-defense. But he is willing to plead guilty to murder because it carries a shorter sentence than heroin dealing does.
The action can be cast as a crime, and can be plead to as a crime, without actually having been a crime.