The law was enforced, but it seems Turing did not take it seriously. He was openly gay since university, complained the law was stupid, was unapologetic in court, and sought out "sex vacations" after his conviction.
Being married is a hard prerequisite for being able to commit marital rape. You don't have to be gay to have gay sex that the authorities learn about.