In the show the good guys are the “family”. It works kind of like the Godfather series, we root for that family against both other mobsters and cops because our introduction to them was controlled to make us like them. We learn early on in The Americans that their Soviet leaders are cutthroat and brutal and don’t have the “family’s” best interest in mind, and of course the FBI wants to capture them, but they’re nice people even if they do bad things so we root for them. It’s a hard balance to setup, but once the story teller succeeds it gives them a lot of dramatic potential, because basically everyone around our good guys is a potential threat and thus a bad guy.
They certainly pulled it off in “The Shield.” Vic Mackey was a terrible, terrible person, but you couldn’t help but root for him.