Even if their entire stack was open sourced, GitHub would still be a profitable company simply because it's GitHub. They're hosting hundreds of thousands of repos on bare metal and providing tools around those repos allowing for the maintenance of a community - that's why they are making money; not because of some secret sauce in the code. Otherwise, GitLabs would have eaten their lunch by now.
I could definitely be wrong, and they do have 8ish pages of projects they offer up themselves, but so many are just meaningless dumps of one-off projects.
a) Have to include a lot more documentation
b) Be a lot more paranoid about best practices, and writing generalizable code even if it doesn't fit their particular slice of the market
c) Never have the chance to use a closed source solution for part of the problem (e.g. no we can't have half our app actually be a series of Oracle specific stored procedures, or buy a UI package for $20,000 rather than use a heavily modified version of Bootstrap).