Why do commercial firms contribute to Android open source project if they are not bound to. They can build their own version of android and use it with their products under any license. Samsung uses Tizen in its products but at the same time contributes to Android. Why? What is the benefit of doing so?
There a few benefits I can imagine in making such contributions.
First, from a practical point of view, I'm guessing such companies have their own patches they'd want to rebase on top of the upstream as it moves forward, in order to consume new features, performance improvements, and bugfixes. The larger these patches are, the harder this rebasing is - so it may sometimes (often?) make sense to donate a patch upstream instead of creating it behind your closed walls.
Second, it's important to support the community. Even if a company has it's own Android fork, it's customer probably don't use just its software - they install third-party apps and games. These third-party apps are usually developed by developers who develop apps for Android, and not for a specific company's Android fork (although they probably test it on several models of the main manufacturers). To ensure this community continues growing, it's important for these companies to make sure the Android market, as a whole, gets a steady stream of new features and bugfixes - and the way to do so is to contribute to the upstream Android.
Third, I can assume there's an HR component here. A lot of developers [this one included] like contributing to open source - it's often a fun experience, it allows for a lot of professional growth (as you're able to get feedback on your work from a wider circle than your immediate coworkers), and it improves your own visibility and personal brand. Companies may recognize this and allow some of the work to be done upstream as a type of benefit for the employee.