Landowners and merchants hired private police to watch over their holdings. Over time, they convinced locals that it would be in the public good if the guards they hired were paid for by everyone.
In the 1850s, in Boston, they formalized this arrangement into the first police department in the country. (There's an interesting history here around the oppression and then incorporation of Boston's Irish population by the police force.)
Edit: Curious about the downvotes -- this is a review of US history.
https://time.com/4779112/police-history-origins/
https://heinonline.org/HOL/LandingPage?handle=hein.journals/...
https://books.google.com/books?hl=en&lr=&id=WLovR6DgNFEC&oi=...
https://plsonline.eku.edu/insidelook/brief-history-slavery-a...
Policing has been a problem for the black community since before your "not racist" reason of detachment from central authority happened.