The whole "what could have stopped X" question is a loaded one. But regardless, the answer is gun control, and U.S. law should learn from modern German law:
https://www.standard.co.uk/news/world/germany-gun-control-laws-a4366996.html
https://mediabiasfactcheck.com/london-evening-standard/
It's crazy how even this right wing sources seems to understand that gun control is necessary and a requirement for low gun death rates, given that they admit right at the begging of the article that they have amongst the lowest death rates out there.
https://en.m.wikipedia.org/wiki/List_of_countries_by_firearm-related_death_rate
Total:
Germany: 1.04/capita
United States: 12.21/capita
Homicide only:
Germany: 0.06/capita
United States: 4.46/capita
If more guns & lax gun laws made us safe, we would should expect to see the opposite. Yet we don't, because anybody with half a brain understands that a tool whose purpose is to kill as easily as possible will make killing easier when it is around untrained people/people with insufficient reason to own it/people who store them poorly.
That's a 75x smaller gun homicide rate. We aren't going to get that small of a rate without gun control.
Inb4 somebody calls me a troll despite putting effort into this: fuck off