In antacid it acts as a base and neutralise the acid that is extra created on the stomach.
HCl + NaHCO3 ------> NaCl + H2O + CO2
on adding water to bicarbonate, the liberation of carbondioxide (in the form of carbonic acid) makes the foaming to occur. This is the chemistry behind the baking powder.
NaHCO3 + H2O ----> NaOH + H2CO3