Stomach ulcers are usually caused by an infection of the Helicobacter pylori (H. pylori) bacteria, which is a risk factor for stomach cancer.