Buffer solutions resist  pH change because of a chemical equilibrium between the weak acid HA and its conjugate base A:
When some strong acid is added to an equilibrium mixture of the weak acid and its conjugate base, hydrogen ions (H) are added, and the equilibrium is shifted to the left, in accordance with Le Chatelier's principle. Because of this, the hydrogen ion concentration increases by less than the amount expected for the quantity of strong acid added.
Similarly, if strong alkali is added to the mixture, the hydrogen ion concentration decreases by less than the amount expected for the quantity of alkali added. In Figure 1, the effect is illustrated by the simulated titration of a weak acid with pK = 4.7. The relative concentration of undissociated acid is shown in blue, and of its conjugate base in red. The pH changes relatively slowly in the buffer region, pH = pK ± 1, centered at pH = 4.7, where [HA] = [A]. The hydrogen ion concentration decreases by less than the amount expected because most of the added hydroxide ion is consumed in the reaction
and only a little is consumed in the neutralization reaction (which is the reaction that results in an increase in pH)
Once the acid is more than 95% deprotonated, the pH rises rapidly because most of the added alkali is consumed in the neutralization reaction.