I would suggest that perhaps, part of what's happening is that the police are optimizing for a particular metric. We can hope that it's crime reduction, or some number or numbers very close to that.
When you optimize for one metric, other metrics fall.
The police, like most anyone, make errors based on superficial attributes. Even if statistically, arresting tall hobo beard man taking pictures of trees late at night is the best course of action for the police's metrics, you perceive it as a series of stupid errors. This leads to a perception of injustice and harassment.
I'm the kind of person who doesn't mind security check ups and even being stopped by police as long as they are cordial and professional, and, crucially, I understand their reasoning. I recall listening to one black man, I think he was talking to Sam Harris, relating how police would stop black men and grab them. Unprofessional treatment creates a perception of an uncivilized society, and that's unjust.