Buffers.
Buffers are chemicals that maintain pH at a very specific range. This is because buffers have an equilibrium that they will maintain that is very stable. If there are too many hydrogen ions (acidic), then buffers will sweep them up and hold onto them. If there are not enough ions in the matrix (basic) then the buffers will release the hydrogen ions and maintain a stable pH.