The mistake was possibly going through red in front of the cop. I always check first. If any of the boys in blue are in sight I wait.
This, obviously.
The issue was that OP was (somehow) under the “impression” that what he did was legal. He didn’t get that he was going through a red light.