They do definitely profit. They either gain referral fees, or they refer to themselves (Play Store) and thus get effectively free advertising (that would cost them money otherwise).
When you click a link to Amazon for a specific book from a third party website, Amazon pays that website money for that referral. It is no different here except that one Google department sometimes sends it to another Google department.
> Fiction: Google is paid by booksellers like Amazon to include links on Google Books pages.
> Fact: We provide links to booksellers on Google Books pages because we want to make it easier for users to buy books and for publishers to sell them. Booksellers don't pay to have their links included in Google Books, and Google doesn't receive any money if you buy a book from one of these retailers.
Google doesn't use the books scanned for profit. If they sell a book is because they already have it in Google Books, is not one of the scanned