Not technically theft unless the public library no longer has the books. Selling something and saying you created it when you didn't is a different five-letter word: fraud.
Putting prompts in an LLM and saying you "created" the image or text thereof is fraud.
AI companies sell access to their models, via subscriptions and ads.
Public libraries don‘t sell anything. Also authors and publishers get payed for having their books in the library (how and how much varies by country). Authors and publishers get nothing for having their books put into AI training data. Hence the former is a public service, and the latter is theft.
Putting prompts in an LLM and saying you "created" the image or text thereof is fraud.