It's kind of been a running thing that the only way to make a group of cops the good guys is to have them point out how bad most cops actually are. There's an episode where Terry gets racially profiled and has to sacrifice a promotion so he can get even a little bit of justice. There's an episode where NYPD posters keep getting defaced, and Gina has to point out how most people hate cops for good reasons. The series starts with Holt pointing out the NYPD kept him from getting promoted due to being a gay black man, then promoted him when they thought it would make them look good.
Heck, all of season 8 is spent opposing a police union and trying to stop police corruption.
It's copaganda that desperately didn't want to be copaganda.