Why do gun and ammo stocks rise after mass shootings?

On May 24, a gunman opened fire at Robb Elementary School in Uvalde, Texas — killing 19 children. This happened less than two weeks after a Buffalo, New York supermarket shooting that killed 10 people.
Historically, gun sales have risen after mass shootings and news of potential legislation.