The U.S. president’s interventions are adding to the unpredictability of local elections thousands of miles away.