Enforcing the law required acting as slave patrols for well over a hundred years in the US. In 1757 Georgia, for instance, the colonial assembly required white landowners to be slave patrollers, and this continued well past the civil war.
There is over a hundred years of law enforcement, particularly in the South, acting as slave patrols. It's absolutely reasonable to trace the roots from modern departments back through the nation's unique history.
Not all police followed that path, like I mentioned above, police in the North were formed more out of an interest of protecting property and landowners. Places like Boston founded their police to try and prevent crime, rather than simply exact justice post-facto. That's a different historical root of American policing, and it did not involve slave patrols.