It’s not a defense but traditionally this was balanced by laws requiring a mens rea component - or a guilty mind.
With the rise of strict liability crimes for everything this balance is no longer in place. The Overton window has moved dramatically from where it was when that phrase was coined.