Just as people commonly attribute magical powers to police to know that someone is lying or has committed a crime despite the absence of evidence, people also attribute a certain amount of knowledge of the law to police. When a cop says you're breaking the law, we assume he knows.
What this encounter shows is that they just make it up as they go along. Sure, they find a dead body with a bullet hole through the forehead and they are likely to be correct in calling it a murder, but that's the rarity. The basic encounter between police and the citizenry entails far more mundane situations, Like this. Like telling someone
they can't stand on a public sidewalk. No horrendous crime. No act of violence. Just people doing stuff that cops think, for whatever reason, they shouldn't do.
Lawyers and judges recreate these scenarios in legal terms, parsing them to an extreme degree to ascertain whether the actions were lawful. Of course, the police have some huge loopholes to use to their advantage, ranging from disorderly conduct to interference with governmental administration to failure to obey a lawful order. Ironically, these are laws used to punish people not for the underlying "crime", the purported wrong that police make up to get people to do as they are told, but for the disobedience of the citizen. The crime is not obeying the cop, even if the cop is pulling his justification for his command out of thin air.
Courts may offer the consolation that we have the right to be left alone
, but that right apparently ends upon a police officer's decision to not leave us alone. Don't try to reconcile the concept. It only exists on paper, and has no bearing on the real world.