Ancient Egyptians largely lived in harmony with one another, but law enforcement still needed to exist to study people's intentions and to punish those who act against the will of society.
Egypt prided itself on being the kingdom that's people governed themselves because of the highly profitable economy. However, when Egypt's population increased to a point where the self-sustaining economy wasn't enough to feed everyone on a daily basis, crime began to spring up.
Due to increases in thievery, Egypt's ruling class hired locals to be police officers. They were armed with wooden sticks and attack dogs, and they guarded the many historical buildings and public spaces that crimes were happening in.
As Egypt expanded, even more, Medjay warriors from Nubia offered their presence to be keepers of the peace,
The Medjay became Egypt's primary police force due to their prior training and sheer numbers.
The former members of the Egyptian police force were appointed as chiefs, but they weren't called Egyptian police-forces anymore, they were called Chiefs of the Medjay.
During the time of the New Egyptian Kingdom, there was a special unit of Medjay police that also served as temple police. Their job was to preserve the sanctity of the temples by ensuring there be proper behavior during religious festivities.