In addition to their ad platform and infrastructure being much more complicated than many people probably assume, as others have stated FB does own virtually every other top social media app aside from Snap and Twitter.
They're also one of those companies that has so much free capital that they throw it into side / vanity projects that aren't necessarily commercial or directly related to the core business, including open source tech. For example, they are behind React, which is one of the most popular and widely-used Javascript frameworks right now. They're a little like Google in that way.
You can see a lot of their open source stuff here:
https://code.fb.com/