I'll try to give a general (hopefully correct) explanation...
Basic buffers, like calcium carbonate work by keeping hydronium ions (H+ or H3O+) "occupied," which would normally contribute to lowering the pH of the solution.
For example, normally, if you added hydrochloric acid (HCl) to a glass of water, this reaction would occur:
HCl+H20--->Cl- (aqueous) + H30+
Notice that since the H30+ is "free" on the right side of the equation, it contributes to lowering the pH (a measure of the concentration of hydronium ions in solution).
First, adding calcium carbonate (CaCO3) to water, it will lower the pH slightly, but it won't contribute OH- ions, so its effects won't be as dramatic on raising the pH compared to if you poured the same mass of of sodium hydroxide into solution (see the paragraph below this for an example).
So if you add HCl to CaCO3, the main reaction would be the following (ignoring other side-reactions that would take place in solution, for simplicity):
2HCl+ CaCO3(s)---> CaCl2(aqueous) + H20 +C02
HCO3- and H2CO3 could also be formed in solution, but in all of these cases, the hydronium ions would be kept "occupied" more often and would not contribute to raising the pH as much.
Just to give another perspective- modifying an idea from wikipedia:
Water can dissolve up to 15.9 grams/Liter of CaCO3 and still maintain a pH of 7. Converting this to molarity, gets you a 0.16 mole/L solution of CaCO3 that will still have a pH of 7.
Compare that to sodium hydroxide, which with the same molarity of 0.16 mole/L (6.4 grams/L) would equate to a pH of 13.2. So calcium carbonate is able to counteract the addition of acids to solution without significantly raising the pH, themselves.
Please, NaN, or anyone- correct me if I'm wrong on anything!!!! I took chemistry 2 and a half years ago, so it's quite a bit fuzzier than it used to be.
And here's a helpful resource I used back in the day to try and understand buffers:
http://www.chemguide.co.uk/physical/acidbaseeqia/buffers.html