Mamdani’s unlikely rise gives credence to Democrats who have urged the party to embrace more progressive, left-wing candidates.