Uniformed police are a relatively recent invention.
In the US and England, the police evolved predominantly out of a desire to socialize the costs of protect the capital interests of the wealthy. This was protecting warehouses and such for the north/Europe, and slave patrols in the south. (As, at that point in history, the slaves were considered property, not people.)
Over time, the police merged -- some from slave patrol origins and some from protecting trade -- into uniformed organizations per city. Some directly trace their origins to slave patrols for sure though.
Other parts of the world saw police evolve from things like shire reeves, the night watch, etc. All of which were considered pretty unpleasant responsibilities -- people would be required to put in a portion of their time as night watchmen, however the wealthy could pay others to take over their shifts. The evolution from "I'll pay you to take my shift because I'm too rich to work the night watch" to "I'll pay for the night watch to protect my stuff" to "wait, what if we had everyone pay for the watch to protect my stuff" is typically the path things went outside of slave owning societies.
Edit: Responding to the Rome post here, because I apparently cannot create more posts right now:
The Romans had a few police organizations, but they were either slaves (who in turn acted as slave patrols) called the Vigiles. Those weren't widespread across Roman cities. They were a small one time thing, eventually absorbed into the military. Mostly they were firefighters.
The Cohortes Urbanae were a similar unit, explicitly part of the military that policed the city of Rome. They were more like riot cops than crime fighters though.
Otherwise, in Roman populations they had night watches like most other European cities. A group of people who were charged with keeping the peace overnight. This was considered a deeply unpopular job in Rome, and was typically given to slaves to perform. The Triumiviri Nocturni, if you want to search for more information.
But none of these are police forces -- they are either night watches pushed to those who had no other choice or they were military units. Using a military to keep the peace is very different from a police force.