Sourness may have been, in a higher or lower level, a common characteristic of beers centuries ago, specially after some time of storage, once the common vessel to keep it was wooden barrels, and wood often harbor a lot of microorganisms, including bacteria and wild yeast, the former being responsible for souring the beer. After the Industrial Revolution, with more hygiene and sterile tools, that characteristic became more and more uncommon, and at some point, undesirable. So, meanwhile, yeast was "discovered", isolated, and fermentation controlled so that we had a clean taste profile, free from acids at all, which is what you know as beer nowadays.
Don't be fooled: what really sours a beer are bacteria, not Brettanomyces. The later, also known as 'wild yeast', are usually found in sour beers as well, but are responsible for other aromas and flavors (barnyard and horse saddle being the most recognizable). (Brett actually produces a tiny amount of acid, no more than that).
Some Belgians have been intentionally making sour beers for centuries, through spontaneous fermentation process (in the case of lambics) and wood-aging (in large oak vats) after "clean" fermentation (in the case of flanders reds). Germans did it too, but their two traditional sour styles (gose and berliner weisse) are almost dead there, and differ from the belgians ones on the absence of brett character.
Nonetheless, nowadays people comprehend a lot better how those processes occur, and are doing sours again on purpose and manipulating those organisms in many ways. Basically, souring bacteria used are pediococcus and lactobacillus (not very different from lambics, actually). Most of the time, barrels are still used in the process, because of the micro-aeration those microorganisms need. And, off course, for keeping the microflora inside it, etc, etc, not to mention the flavor complexity that comes from wood compounds itself.
A contaminated beer may end up being a sour. Well, so what distinguish a spoiled beer from a sour? Nothing actually, except that when people intentionally want to produce a sour, they do that with some more control in order to get the outcome they want and not some weird aleatory taste at the end. But, at some level, producing a sour beer, specially when using barrels, is always unpredictable too.
As you can see, it's a rich and complex topic, probably the most exciting one about brewing.
As suggestions, I definitely encourage you to taste the classic ones, belgian lambics (any Gueuze you find) and flanders reds (have you ever heard about Rodenbach and Duchesse de Bourgogne? they're amazing). I love Petrus Aged Pale too.
And, if you are from US, then you are bloody blessed, because american craft brewers are doing sour/wild beers like there were no tomorrow. =P Look for Allagash, Russian River, Lost Abbey, The Bruery, Avery, Boulevard, Almanac, Deschutes. The list is infinite. The thing is getting so serious that in the last years, all-sour breweries are popping up, like Rare Barrel from Berkeley.