The ruling blocks a Trump-era effort to purge so-called “woke” books from classrooms serving the children of military families.