Lando Norris won the Mexico City Grand Prix to seize the lead of the world championship for the first time since April.