Google also makes the most popular mobile OS in the world, the most popular web browser in the world, runs a major cloud provider, runs an app store, and provides services in hundreds of countries which requires a large amount of employees to do all the legal, compliance, localization, and support work.
Android Open Source Project may be free but check out any Android phone sold in the west at least and it will be loaded with closed source Google software.
That is a good business. But the point is still pretty clear that Google seems to make very large investments into products that are then given away for free to many/most users (Search, Chrome, Gmail, the whole Google Workspace product suite, YouTube) with the no obvious business plan other than to drive ad revenue, sometimes in ways as indirect as just having people spend more time on the Internet.
The most popular mobile OS in the world that according to evidence that came out in the Oracle trial, only made Google $27 billion in profit from inception until then.
For reference, Google pays Apple a reported $14 billion a year to be the default search engine on Apple devices. It’s highly likely that Apple makes more from Google in mobile than Google makes from Android.
Chrome is just another gateway to advertising.
Google’s Play store game revenue is $48 billion a year. But if they count revenue like Apple does, they are counting the gross amount people pay net after they give developers their cut is 30% of that excluding other expenses.