None of these companies sell software; they don't even sell platforms. Rather, each has built a business that's powered by open source software, and each has gone on to create new projects that developers all over the world want to use. Those developers don't compete with them. Rather, they have a vested interest in the code they are using, so they fix bugs and develop features.
When smart developers do that, they realize that contributing back to the original project makes more sense than sustaining a fork of the code themselves. Thus, they contribute. Some model this as a "gift economy" -- and there's no doubt that a sense of community is important for open source developers. But fundamentally this is about self-interest and making sure the code ends up in a place where the most people will be motivated to use and maintain it.