Sodium hydrogen carbonate or magnesium or aluminum hydroxide neutralize the excess HCl present in the stomach. They do not treat the root cause for the release of excess acid..
Cimetidine and ranitidine control the root cause of acidity and decrease the amount of acid released by stomach.
Note: Acidity is due to the release of excess acid which in turn is due to the interaction of histamine with receptors in the stomach walls.