Salaries are also deductible, so they get the talent in their pool, off the market, adding a small % of value, whilst also being able to offset taxes on record profits.
It's a pretty nice win-win for them.
Eg. Fuchsia OS might have been started because Google saw a bussines oppurtunity in writing an open source capabilities OS. Or, it might have been started to keep smart OS engineers from leaving the company.
Android has a bit of a better claim, as more of the userspace stack was written for it. It also wasn't started by Google (although they bought Android Inc. years before it was released publicly).
The idea it's just a Linux flavor is sort of like saying iOS is "just a build of OSX". I.e., gross simplification.