Mayor Zohran Mamdani directed city agencies to make plans to comply with rules governing health and safety at the facilities, and said they must work to end solitary confinement.