It wasn't until 1982 that the bacterial cause was found, and it took years for the medical community to abandon the "caused by stress" explanation and apply real treatment.
partly explained here: https://en.wikipedia.org/wiki/Helicobacter_pylori
It's well known that chronic stress weakens the immune system, and makes it easier for a bacterial infection to take hold.
So a more complete hypothesis is that stress can be the cause, whereas weakened immunity and consequent bacterial infection is the mechanism.
Of course, anything else that causes the immune system to be weakened can also be a cause.
As user interpenetrate has articulated in more depth, the error is in the need to identify a single, simple "cause".
Susceptibility to flu is influenced by immune system fortitude; that's uncontroversial. That stress is one factor (among several) that can weaken the immune system in an otherwise healthy person, is surely useful to consider when making life choices.
I notice in myself that I often get a sore throat after being stressed and not sleeping enough.
It seems like people had symptoms that were mistaken for stomach ulcers in the popular knowledge of the time. The incidence rate going down for stomach ulcers after learning more about stomach ulcers tells us nothing about what happened to those people. We don't know what they were really suffering from, what they might now-a-days be diagnosed with, etc. And we aren't told anything here about what other environmental factors may have led to a decline.
the question is one about etiology. the history suggests that the popular etiology (bacteria and probably also NSAIDs linearly cause stomach ulcers) is entirely insufficient. the questions you're asking ("we don't know what they were really suffering from") are important, but to most people these questions don't matter anymore. there is practically no medical research being done on these questions today. why bother? the "psychosomatic school" is the only school who takes the issue seriously anymore. their work is worth considering, that's my point.
The possibility that there's at least a component of the illnesses that aren't psychosomatic is worth considering, but such a school of thought has always been on the fringes, and serious funding to examine actual causation has always been a challenge for illness communities that have offhandedly been thrown straight into the looney bin.
A more complete telling of the story may be that researchers ingested a volume of the bacteria that was more than their immune system could easily contain, and got ulcers.
Given that stress is well known to be a cause of immune system impairment, this could still be an upstream cause of the bacterial outbreak that then leads to ulcer formation.
Totally psychosomatic.