It's complicated because the District Attorney is usually responsible for seeing cases against police and deciding to bring charges but they rely on having a good relationship with the police.
The high profile stuff you see on the news are the hard cases. Most of the time the instances where people say they got away with something are very biased takes that leave out a lot of context rather than a successful cover-up, though both do happen.
People talk about qualified immunity like it's a personal shield for police but it's much more nuanced than you'll read about most places. Qualified immunity just says that the individual police officer has immunity from prosecution or liability in cases where they genuinely believe they are doing their job correctly.