I don't believe in banning books generally.
However, libraries should have a responsibility not to be biased in pushing one particular belief, especially where that is contentious.
I'd rather have legislation that required books that could be used to persuade children to adopt such a belief, to have a front page that gives some facts and signposts to appropriate other texts to read too.
Eg "This is a book of fiction and the characters aren't real, but some of the people you meet in the real world will also have some of the same ideas. Some people believe it is possible for girls to become boys and boys to become girls, but scientifically this isn't possible. No one should be bullied for their beliefs, and it is ok that we don't all believe the same things. After you have read this book, maybe you will also enjoy (insert names of a few similar-reading-age titles where children are allowed to enjoy the activities associated with the opposite sex without having to believe in the magic of genderswapping)"
Children are going to grow up in a world where they encounter people who believe in genderfeels. I would rather they encountered the concept while they are young enough to be reassured that it's just one of those slightly bonkers things that some people believe in if their grip on reality is tenuous, like horoscopes. If they are shielded from it while they are young, they may encounter an evangelistic true believer at that vulnerable age when teens start thinking their parents are generally stupid and ignorant, and then it's much more difficult to protect them.
With legislation requiring that a suitable age-appropriate statement like the above must be attached to any ideologically-biased book in libraries and schools, it's not a ban but the the onus is on the adults to be aware of their responsibilities, and the difficulty of composing something age-appropriate for a very young child will ensure that those in charge of choosing which books to stock will swerve away from books with any ideological bias.