The mayor-elect’s turnaround came as he selected Kamar Samuels to lead New York City’s school system at a precarious moment.