A public library buys the book. Many people can read it, but it guarantees one purchase, and often many libraries will buy the book. It also limits the amount of readers to those who live relatively nearby. Books were also traditionally written with the ideas of libraries in the author's mind, and also many authors benefited themselves from libraries.
AI Digital art has many facets which make it detestable for some: it floods the market with stuff that can be generated at near zero cost, it weakens the connection between people because people are no longer looking at something another human created, it cheapens the spirit of creation.
While libraries, Library Genesis, and piracy might have some facets in common, they are separate entities and should not be conflated in any sense.