In other parts of the world the police's chiefs are selected by the city mayor or the city council, but in almost all counties of United States they are elected.
- Why are they elected, and not selected by the mayor?
- Has it always been this way?
A Sheriff in the US is also usually a county or city official, which are traditionally elected. There are exceptions, however, the Sheriff of New York City is directly appointed by the mayor.
The duties of the Sheriff are relatively static, and usually uncoupled from the efforts of appointed law enforcement officials. There's no real reason why a Sheriff would need to be appointed to be more effective in his or her office (in most places), so it remains an elected office allowing for the people to determine if a changing of the guard might be in order.
Depending on the location, the duties of a Sheriff might be almost or completely ceremonial, for which term elections would make sense.