Uhm... it doesn't have to be an acid - bases can be buffers, too. But your antacid is an acid.
A buffer IN GENERAL is a weak acid and its salt, or a weak base and its salt.
Basically (hah, get the pun?), when you add the weak acid and its salt, you are setting up an equillibrium reaction:
HA(aq)
H<sup>+</sup>(aq) + A<sup>-</sup>(aq)
Where HA is the weak acid, so the equation will lean to the left. Adding the A<sup>-</sup> anions from the salt will make it go even further left (La Chatelier's).
You've got lots of unionsed HA acid, lots of A<sup>-</sup> anions, and enough hydrogen ions to make it acidic.
Since the acid is weak, it will supply very few A<sup>-</sup> anions - rather, it will be the salt which supplies the bulk of them. Remember the salt is a mix of the anions of the acid HA and the cations of some base.
If you add an acid, such as stomach, new hydrogen ions will pop up - which will increase the acidity. Therefore, the buffer must remove these new hydrogen ions, and it does so by making its anions A<sup>-</sup> attach to the hydrogen ions, making weak HA acid. This will remove most of the new hydrogen ions and the pH won't change much.
In terms of stomach acid, adding a buffer, HA will effectively turn strong stomach acid into the weak HA acid and so lower the acidity.