Traveling the boroughs. Fighting the mayor. Courting those close to the governor.

New York City officials are positioning themselves for 2021, when Mayor Bill de Blasio is term-limited out.

Campaigns won’t begin for years, but the race will affect city politics long before that, said current and former officials. Potential candidates are already...