In official legal terms, unless otherwise contracted, the Copyright for source code is owned by the developer, not the customer. In order for the customer to "officially" buy the copyright and distribution rights, requires a great deal of bureaucracy ("red tape"), involving contracts, notaries, layers, etc. It also usually entails a lot of money to be paid to the coder for such exclusive rights!
So, in 99% of most "Freelance" coding services, here on this site or anywhere else, you are for the most part only getting a provided service to have your idea coded for you for your own personal use only. Anything else you think you are entitled to, is mostly a "gentleman's agreement", than actual legal rights to be able to commercial distribute it or claim ownership or copyright. The only thing to which the customer can claim ownership or copyright, is the idea or your strategy, but not the source code.
Thanks for your answer.And if the source code is a mixture of several source codes from different developers, who has the right to distribute it commercially?
The short answer, is that you cannot distribute it commercially without the express legal permission of all the authors.
Each part has its individual copyrights, and the final developer only has the right to use that source code with express permission of the original coder or if it was provided via Open-Source, but in each case, each coder must be credited in the final source.
However, in these cases, specially for Open Source code, it usually has to remain Open Source and no one has the right to distribute it without the source code, and in many cases cannot even be distributed commercially at all.
Please note that this is in the spirit of the law, but many people, including both coders and customers, constantly violate these rights.