A buffer solution is resistant to changes in pH upon the addition of relatively small amounts of acid or base. In this case, the equilibrium resisting changes to the pH is: H2CO3 <-> H+ + HCO3-.
Upon addition of acid;
H+ reacts with HCO3-, forming H2CO3, shifting the equilibrium to the left.
Upon addition of base;
OH- reacts with H2CO3, forming water and HCO3-, shifting the equilibrium to the right.