macOS being free is sleight of hand. The cost is just baked into the margin on their hardware. Maybe if you could run macOS on hardware of your choice (i.e. "hackintosh") it would be an apples-to-apples comparison.
Similar with free beer. You need to do _something_ to get the free beer. It will probably cost less than the airline ticket, but it will still cost.
Oh no! Wait, why is this somehow a concern? You buy a Mac and get an OS with years worth of free updates to that OS and additional years of security updates to the OS. Where's the problem?