Thanks for your question.
The gift of infallibility
prevents the Church from teaching error in area of
faith and morals.
An index of forbidden books is not a teaching. It's
the implementation of a discipline. The Church for
pastoral reasons banned certain books during the
Reformation. That might seem a bit extreme today
but we have to look at the historical context. At
the time, the Church was concerned with preserving
the orthodoxy of the laity.
At the time, the laity did not have access to all
theological works, much like they do today. Moreover,
the laity was mostly illiterate. The point is, that
the Reformers, with the advent of the printing press,
were publishing heretical writings at a great pace.
These books were being distributed and read to Catholic
laity, exposing them to heresy. The same laity did
not have the benefit of being able to read authentic
Catholic Teaching, because it had yet to be published in
mass, like the heresies being promulgated
by the Reformers.
The Church's solution was to ban the reading of heretical
works. This was temporary solution, that perhaps
lasted too long, but I wouldn't be to quick to pass
judgment on the Church's decision.
The gift of infallibility doesn't really come into
play here. The Church certainly had, and still has,
the authority to impose a discipline on the faithful.
That doesn't mean that the discipline is the same
as an infallible matter of faith and morals.
In short, The Church can infallibly discern doctrine.
In so doing, She infallibly identifies heresy. Whether
or not the Church decides to allow the faithful to
read the heresy, is a discipline which is not protected by the gift of infallibility. The faithful nevertheless
are obliged to obey the discipline in humility, recognizing
that Holy Mother Church has been given the authority
to impose disciplines for the benefit of the faithful.
I hope this helps,