Zohran Mamdani, a state assemblyman and democratic socialist, had a commanding lead over former Gov. Andrew M. Cuomo, who conceded in the Democratic primary.