The buffer solution is a mix of an acid (#HA#) and its conjugated base (#A^-#), or a base (#B#) and its conjugated acid (#BH^+#), which has a simple, intuitive mechanic.
If you put an acid in there, the base will be protonated, the equilibrium restored and the pH will be returned; if you put a base in there, the acid will protonate it, the equilibrium restored and the pH will be returned. And if you pour something indifferent to acid-base mechanisms, the additional volume will dilute both acid and base equally so the pH won't change.
They'll still give way if a big amount of volume is added so they're diluted or if enough acid or base is reacted to react with it all.
Buffer solutions follow the following equation:
#pH = pK_a + log([[A^-]]/[[HA]]) = pK_a + log([[B]]/[[BH^+]])#
Where #pK_a# is minus log the acidity constant of #HA# or #BH^+# and the square brackets represent concentration in moles per liter.
So we can see that usually we make a buffer solution near the #pKa# of the species in question because we need to have a decent concentration of the species (around 2 mol/L of each) or the buffer will give way too quickly, and to raise or lower the pH by 2 points, you need to have 100 times more of one than the other.
Common buffers are #H_3PO_4()/()H_2PO_4Na# (phosphoric) for strong acid pH (around 1), #CH_3COOH()/()CH_3COONa# (acetic) for slightly acidic pH (around 4 or 5), #NaHCO_3()/()Na_2CO_3# (carbonate) for neutral to slightly basic pH (from 7 to 8), #NH_4Cl()/()NH_3# (ammoniac) for basic pH (from 8 to 10).
Buffers are useful for making sure a reaction will stay in a given pH range, which can be extremely useful when dealing with compounds that can easily precipitate or react with #OH^-# or won't be able to happen in acidic medium (like the reaction of magnesium with EDTA, which needs to happen in pHs from 9 and up), or in cases which involve microorganisms or enzymes which will die or stop working outside a certain pH range. Or, like the one in your stomach that makes sure drinking some acid lemonade won't cause intestinal trouble.