A federal judge has ordered the Department of Defense to return nearly 600 books on race and gender to libraries at several U.S. military schools.