Actually, that is not the reason why they should exist. That is the story you are told. But this story has never been true, the propaganda is just a bit more effective these days.
I mean. Look at: Paw Patrol, Miami Vice, Tokyo Vice, the Wire, Criminal Minds, Chicago PD, Southland, Bosch, Law and Order: all of them, law and Order: all of them, CSI: all of them, Luther, The Shield, Reno 911, etc.
I mean this list is just from the top of my head.
We are being indoctrinated in our image of the police. Some rotten apples are shown, but in the end they are always The Good Guys.