The short of it, is that a mining program decrypts an encryption via bruteforcing, and several websites have it set so that you and other miners can work together so that if either of you find the code that cracks it, it then doles it out to everyone based on how much workload everyone put towards gaining that bitcoin.
Of course, if you were to find it alone without working together, you'd have all of the profit, but that's pretty dang rare since there's millions of people out there doing this. Unless you had a botnet, that is.