It can be just as fast and easy to order an ebook from the library as to buy it online, and it costs nothing. Why would anyone buy an ebook from the publisher if the library has it for free?
So why would a publisher sell ebooks to libraries?
This is a legitimate, big problem, which affects authors just as much and as directly as it does libraries and publishers. It has no quick fix. To solve it will take a complete and painful rethinking and re-organisation of the whole publishing industry.