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.
You say (correctly) that there was a law against gay sex, and that this law was enforced, but also that Turing's prosecution and punishment under this law (after admitting to a police officer that he'd had gay sex) somehow had nothing directly to do with his being gay. I'm not quite sure how you square that circle.