> They don't keep every book though.
In France they do! And other countries too I think. The French national library is also scanning everything (or trying at least) including copyrighted material (but you can’t access it except if you are a researcher and from their own physical place last I checked)
This has been a requirement in the US since 1790. It is called mandatory deposit: https://www.copyright.gov/help/faq/mandatory_deposit.html
They don't keep every book though.