Well, he doesn’t realize he’s tracking dirty cops almost until they start shooting at him. At first it seems he thinks the cops just hung a mass killing on some black suspects because they could – he doesn’t get it until later that the cops actually did the killing.
BTW, I highly recommend the James Ellroy novel of the same name which inspired the movie. There are no good cops in it, no good motives, it is one of the bleakest crime novels ever. Any good outcome is chance or coincidence. And unlike the movie, none of the bad cops find redemption.
I’m not even sure Spain’s Policía Nacional has an actual “IA Department” or people get assigned to specific internal cases on an as-needed basis, but one of the things I liked about a movie I watched recently, No habrá paz para los malvados (“No peace for the wicked”), was the treatment of the cop who was handling the murder investigation and realized it had to have been a cop (and who). They went to a lot of effort to make every single character understandable - maybe nice, maybe assholes, maye rotten to the core, but you could see where the actions of any of them made sense within his own world.
Well, I guess your average cop knows all about hassling and/or arresting people just because they pissed you off (whether or not they were actually doing anything wrong), so I can understand their fear and resentment.
[For the record, police are doing an important job, and there are many fine and honorable people doing so. But I think our police could use a large dash more professionalism]
It’s just that the corrupt cops ruin the reputation of the other 5 percent.
I don’t find the OP’s statement that “In fiction there’s nothing worse than a dirty cop” to be accurate at all. When I was proofreading, I complained frequently how often police characters were given a pass for behavior that other characters would somehow receive comeuppance for. It extended into movies and TV as well, and TV Tropes accepted my “Untouchable Authority Figure” over it.