Bismuth compounds work by coating the stomach lining and intestines, which helps to protect them from stomach acid and reduce irritation. Additionally, they have antimicrobial properties that can help eliminate certain bacteria, like Helicobacter pylori, which is associated with peptic ulcers.