Yes—the Holy Spirit protects the Church from error when she teaches infallibly (e.g., ex cathedra definitions or universal teachings consistently held). But not all Church statements are infallible, and councils are only protected from error when defining doctrine according to proper conditions.
Vatican II itself claimed to be pastoral, not dogmatic. It defined no doctrine, imposed no anathemas, and explicitly stated that it was not invoking infallibility. Therefore, it could—and did—contain errors and ambiguities. The Holy Spirit does not prevent men from abusing their office or promoting confusion. That’s why the faithful are required to judge all teachings by prior defined doctrine, not by who speaks them.