To put it simply: the same reason why you have different tools on your toolbox in your garage. Some tools are better suited for the job. The hammer does a better job of driving nails down than a screw driver would and the opposite is true when a screw driver is better for driving a screw in than a hammer does. Another person can may think “Hey! I bet I can combine all these tools and put it in one pocket.” then they invent the swiss knife.
For example: R programming language is great for data mining and statistics while Java is good to write apps for different operating systems while PHP is a popular scripting tool for most web applications.
When learning how to write code, try not to bother learning all of them and simply pick one specialisation you like to take and then work from there.
At the end of the day it is the finished product that matters, not the tool.