Gamma-ray bursts are cosmic popcorn. In a pot, kernels explode chaotically. In the universe, a dying supernova collapses into a black hole, a superdense sphere, or a supermagnetized object. An accretion disk forms around it, from which plasma jets shoot out, like kernels popping. Blobs crash into each other, creating gamma-ray light. Scientists used satellite data measuring brightness and colors of the rays, adjusted for redshift (the Hubble effect). A self-learning algorithm tried thousands of combinations, and through computer modeling produced bursts indistinguishable from real ones. Even a simple model where blobs fly out like popcorn accurately predicts observed data, if you factor in Einstein's theory. In a second, such a burst releases more energy than the Sun will in its entire lifetime, but due to the vast distances, only a harmless ripple reaches Earth.
The number of blobs in a gamma-ray burst follows the same rule as earthquake magnitudes: many weak ones and few strong ones.