What is a legal defense?
A legal defense is a bar to a conviction. That is very different from being not guilty.
Entrapment, self defense, insanity, duress, these are legal defenses. In effect you are saying yes I did it but you can’t convict me.
The problem with asserting a legal defense is that you have to admit your guilt and then prove your legal defense.
A legal defense is created by statute or by court rule.