You say "JUST" as though that were some trivial change.
Questions of the form "How to do X" are perfectly legitimate on Stack Overflow. We have many of them, and they are highly useful, so long as X is reasonably bounded and scoped for the technologies in question.
Changing "I want a library that does X" into "How do I do X" is not a minor change. In the library seeking case, the only correct answers are libraries that perform X. In the how-to case, valid answers may well involve some library, but a complete answer would also deal with how to use the library to accomplish that task. This represents a fundamentally different question. And therefore is deserving of reconsideration with regards to closing.
Indeed, this is particularly important for some newer technologies that are heavily reliant on centralized repositories of thousands of "libraries", some of which only consist of one or two utility functions that do a single, specific thing. We don't want to limit peoples answers to just "use this library", but we still want "use this library" to be able to be part of a good answer.
We shouldn't treat the word "library" like it's an automatic disqualification.
is close reason "recommending tools" valid only when OP has clear intent to do so (eg:the question parts mentions "library"), and irrelevant to the question background (e.g.:something like "I tried using library A but it is not working")?
What libraries someone has available may well be important for solving their problem. Also, if "it is not working" is detailed to some degree, then answerers will know more about the specific reason why that tool didn't work and therefore may be able to explain how to make it work. In either case, such a statement does not mean that they're looking specifically for a library that does that.