In a surprise ruling cheered by nurses, doctors and others who have fought to keep a Brooklyn hospital open, but which may have muddled its fate even further, a judge on Tuesday ordered the hospital to be returned to its previous owners, nullifying a 2011 transfer to the State University of New York. In the eight-page decision, the judge, Carolyn E. Demarest of State Supreme Court in Brooklyn, castigated SUNY for trying to shut down Long Island College Hospital in Cobble Hill, which she said was transferred to the state university system with the understanding that it would continue to serve the community as a hospital.