As for why Facebook chose to go with Linux and CentOS, you can find them talking about it.
From a presentation of their own - Running CentOS on the Facebook fleet
page 8 :
- We move fast ; opensource moves faster
- We don´t need to write everything ourselves
- Sharing our code means sharing the maintenance and have others extend it
page 9 : why CentOS:
- Stable releases
- Binary compatibility
- [Frequent] Security updates
- Mature and well understood tooling
- EPEL
- Close relationship with Fedora [and RH]
page 10:
- Backports from Fedora Rawhide for stuff we care about
- CentOS + FTL = stable distro, moving fast
page 27:
- every two weeks we sync down the latest updates
Also, in my own experience, in the past when I went with Debian in consulting projects, and the two Universities and three ISPes were I worked, it was due to:
- having the know how;
- being heavily used and supported by a big user community;
- being pretty well documented;
- the malleability of the package management to save me work managing several systems and keeping them up-to-date - and having specific deb versions in my local repository of packages compiled by myself;
- not being a pain in the ass managing the bureaucratic side of licenses;
- the chance of highly customising it to my needs;
- it being slanted towards development, that I needed to do;
- it supporting well the hardware, and later on VMWare Enterprise;
- being well supported by devops tools;
- the availability of debugging tools;
- having the source code;
- being somewhat more stable than alternative distributions due to using more tested software and their unstable->testing->stable release cycle;
- having regular security updates, often faster than other distributions;
- having regularly new versions.
In many organisations they might have similar reasons for their OS of choice.
In my case, cost was never the most important factor. However I guess that in organisation that boasts having hundred of thousands of systems/containers, that will certainly play a more important role.