To simplify: Bitcoin miners race to discover a code that gives them 50 bitcoins. This code gets harder to find each time it is found. This decision is pre-baked in using the bitcoin system (other e-currencies have different traits.)
If you join a mining pool then you split the 50 coins with everyone else in the pool (and they'll split with you) if you are the lucky machine than found the code.
The analogy is pretty direct: mining is the same as going and doing work to dig up gold, buying from the market is the same as buying gold in the market.