It's very hard for a non U.S citizen to see this happening so regularly and wonder what can be done to stop it happening again.
On a holiday to the states a few years back I went to a gun range where you can shoot a variety of guns, it was great fun and I was shocked by the power of them. Was nothing like in the movies or video games, couldn't imagine pulling out an Uzi in each hand and actually hitting anything! After blasting away with the Dirty Harry hand gun I asked the attendant how easy it would be to buy if I was a resident, he said I had to fill out a background check form and wait 24 hours and i would be taking it home. Not being critical but that's shocking to me.
We had a gun buyback here 20 years ago after a mass shooting. It hasn't stopped murders but there hasn't been a mass shooting since, but like you would expect, criminals don't seem to have any problems getting their hands on illegal guns but farmers etc. can't use a semi auto rifle to control pests.
No easy answers for this one I'm afraid.