It's probably more accurate to say that libraries have narrow exemptions specifically for preservation and scholarship purposes, especially for works that cannot otherwise be obtained at a reasonable price. Libraries and similar certainly don't have a blanket "Get out of jail free" card for reproducing and making widely available in unlimited quantities digital reproductions just because they're a library.
https://www.law.cornell.edu/uscode/text/17/108