Any city of the first class, city of the second class, or village may, under the provisions of the Interlocal Cooperation Act or Joint Public Agency Act, enter into a contract with the county board of its county for police services to be provided by the county sheriff. The county board shall enter into such a contract when requested by a village to do so. Whenever any such contract has been entered into, the sheriff shall, in addition to his or her other powers and duties, have all the powers and duties of peace officers within and for the city or village so contracting.