Sadly, most people don't hear of all the good cops that are out there and it is a very thankless job.
For all the dozens of good cops there are, one bad one makes the news and it's "those dirty cops".
Sometimes the bad cops just don't push the limits enough to actually get fired. The get warnings and suspensions and maybe even appear to straighten up, or they get better at not getting caught. But for they most part they get weeded out.
Wherever there are people, power/authority and money, there will be corruption and abuse. Some cops will abuse thier authority and some think they are above the law. Some will kill, others will take money from drug dealers.
Sure, some people become cops because of thier ego, they want to bust people up and use the badge to push people around. Some become cops because it's a stable, "civile service" job with decente steady pay and a good retirement. Then others who really want to do something meaningful. And perhaps combinations of reasons.
But once you get in, it's a hard job to keep if you don't have the right motivation for being there.
So in the long run, most cops are incredibly decent people who care deeply about the community they serve. It would be impossible to risk your life on a daily basis, dealing with all sorts of scum and have the scorn of the public heaped on you if deep down you really didn't care.
I'm sure that every day, good cops hear from criminal lawyers, the press and the public and just think "I should just quit. I don't get paid enough to put up with this crap". But then, the next shift, the badge goes back on and they put thier life on the line again.