Sour or acidic flavor in beer is nearly always caused by bacterial infection.
There are two major types of bacteria used for souring beer. Lactic acid gives a smooth sourness that can be reminiscent of yogurt. Acetic acid gives a sharper, tangier bitterness. See the individual entries for each type of acid for more information.