Why are police unions a major, perhaps even primary, source of corruption?
The unions negotiate extremely generate contracts that allow for incredible protections for police, creating extremely perverse incentives.
Let's take three cops, Rafael, Fred and Charlie. Rafael has some anger problems, Fred is overweight and out of shape, and Charlie takes his work seriously.
Rafael is accused of viciously beating suspects during their arrests. His violence is unnecessary and often unhelpful when arresting people. But when he is charged with misconduct, the union contract gives him incredible protections. He gets a hearing, a chance to review the evidence and, most importantly, are investigated by fellow members of the union. So when he is investigated, his actions are always found justified based primarily on his say-so. So he continues in his position.
Fred is fat. Fred has no physical ability, can't chase suspects and can't fight. He can kinda shoot, but that's it. He's still on patrol because union rules prohibit police leadership from sidelining him or firing him for not being able to perform his job. When there's a fight, Fred draws his pistol. He's too out of shape to actually fight, so he relies on his gun instead. Naturally, he's involved in a lot of lethal-force encounters, but he's investigated by fellow union members, so he's always cleared.
The incentives for the union favor protecting exactly these kinds of people: people who, for various reasons, are terrible at their jobs. For police unions, that means the violent, the lazy, the overweight, and the stupid. These kinds of people are dependent on the union for their jobs, because in a fair employment environment, they would be fired. This insures their loyalty to the union.
Charlie is a good cop, the kind that people actually want to be a police officer. Professional, courteous, serious and the kind of person who doesn't use excessive violence or acts aggressively just to assert himself. He is not the kind of person the union wants to remain on the force, specifically because he doesn't need the union to protect his job. When he finds corruption or criminal activity and reports it, other officers, loyal union members, will turn on him and drum him out.
Unions protect their members, not the public. This attitude not only impacts negotiations, where they negotiate for unpayable pensions and benefits, but general police attitudes. Older police attitudes were about putting themselves at risk to the protect the public. Today, police put the public at risk in order to protect themselves. You've heard police talk about their top priority being getting home every night. That's not what they signed up for, if they wanted a safe job they could've been accountants.
The only real solution is to outlaw police unions, stop negotiating with them, and return to policing with a focus on protecting the public, not force-protection.