In medieval times, the people who wanted to buy a book paid someone to copy it from a library or private collection. [1] There wasn't much circulating availability.
All nontrivial libraries were costly organizations, and their basic income was whatever the founding organization gave them. In the case of monastic libraries, this was the Church. In the case of private libraries, this was generally the nobility and, in some cases, notable burghers.
However, these libraries also had a variable income opportunity in selling people access to books for scribing.
For any library that cares about making money beyond what basic income their owner/patron grants them:
The book seller I initially mentioned isn't going to conjure the prior copies from thin air and make loads of money. The library is aware of book prices. The library can therefore charge people who want to copy books. As allowing those copies increasingly decreases the exclusivity they enjoy for future scribing, this will not be pocket change. As the price of books is well known to libraries, this will not be cheap.
That is what I imagine the business model of contemporary libraries caring to do business to be.
1.https://www.khanacademy.org/humanities/medieval-world/medieval-book/making-medieval-book/a/making-books-for-profit-in-medieval-times