Antacids function by neutralizing stomach acid, providing quick relief from symptoms like heartburn, indigestion, and acid reflux. They contain basic compounds such as calcium carbonate, magnesium hydroxide, and aluminum hydroxide. These compounds react with hydrochloric acid in the stomach to form water and salt, thereby reducing acidity.