(This piece is based on an article from http://brewbeeranddrinkit.com/blog/ and a few other books)

There is a vast difference between savoring a proper sour beer like a Belgian Lambic and spitting out a sour Pale Ale while dropping your glass in disgust… Whether intended or due to defects the sources of the sour taste are pretty much the same.
In some beer styles, brewers purposely add souring agents, while in other styles the presence of sour notes or even overpowering sour flavors are simply due a defect in the beer or brewing process…

Typically beers that are supposed to be sour are: Belgian Lambic beers, Berliner Weisse, sometimes Belgian Witbier, Belgian Oud Bruin & Flanders Red.
Pale Ales, India Pale Ales, English Ales / Bitters, normal Weiss beers, etc. are not supposed to be sour, unless intentionally soured by latter additions of souring agents.

Now the question is: What causes the sour flavors?

First and foremost lactic acid is one of the most common souring agents found in beer. Lactic acid is produced by Lactobacillus.

The next unwanted bug commonly known to get into beer is Acetobacter. Acetobacter produce acetic acid - a vinegar-like acid. This can make the beer taste a bit like cider. Acetobacter needs oxygen, which means it’s likely to get into your beer if you are allowing air and oxygen in during transfers.

Pediococcus is another bacteria which produces the same lactic acid that lactobacillus produces. Unlike lactobacillus this bacteria also produces a buttery flavor when consuming the sugar in the wort or beer. Buttery is another common off flavor in beer.

If these bugs are used in fermentation the usual method used to combat this buttery flavor is by using the wild yeast Brettanomyces, or more commonly referred to as Brett. Regular brewer’s yeast consume the sugars in wort and turn them into alcohol, but they don’t consume all sugars, only certain types. On the other hand Brett consumes all types of sugar. Brett is feared in breweries because it can really cause damage if not controlled properly.