Another point of consideration is that police in any local jurisdiction are specifically hired to protect and serve the interests of local taxpayers. Is this corruption? I don't think so.
In a close-knit community, social justice often takes precedence over legal justice. Take the hypothetical case of a mayor's teenage daughter who gets pulled over for speeding. Instead of a ticket, she gets a warning and her dad gets a phone call. Word gets around, the family is embarrassed, daughter gets her keys taken away. Does she learn her lesson? You bet. And all without the involvement of the courts. Would giving her a ticket have made the community a better place? Unlikely. Rather, using the law as a weapon against normally law-abiding taxpayers for their occasional indiscretions creates far more problems than it solves.
Now take a vagabond who rolls into town. There is no way to bring social pressure on him to conform to local norms; he has no attachments, doesn't care what people think of him. So law enforcement preasure is the only viable method. The moment he is observed committing an infraction, no matter how petty, he is encouraged to pack it up and get lost. This is why so many towns have criminalized common vagabond behaviors, including overnight parking. It gives police the legal power to enforce the desires of their constituents regarding vagrants, nomads, and other "undesirables".
We all have a right to travel; that is undisputed. But we as nomads do NOT have a right to make ourselves at home within a community. That is a privilege, subjects to the terms & conditions (or whims) of the community. Some communities have a strong antipathy toward "vagrants", and this attitude is clearly revealed in law enforcement action. Often, harassment and intimidation practices go beyond the bounds of what is legally permissible. This is wrong...but on the other hand, we have no legal right to demand that a settled community welcome us with open arms. Nomadism is not protected by any anti-discrimination laws.
So what should you do? First and foremost, show respect for the traditions and sensibilities of the communities we visit. 99 times out of 100, you will be welcomed and have an enjoyable stay.
Second, if you are given a hostile reception, don't argue, hit the road! If you feel an LEO's hostility was personal and not professional, consider pursuing redress with the local government. Money talks, so remind them of the economic boost that travelers bring, and the damage wrought by unreasonable hostility toward travelers.
Third, stand up for your rights! While you have no right to live in or do business with any particular community, you do have a plethora of other rights that MUST be respected by business and government officials. Know your rights, and exercise them in a calm and peaceful manner.