WARNING!!! Completely not-necessarily-factual post follows:
I’ve always assumed it originated with capguns. You know, the little fake sixguns that opened up to load a roll of caps? And when you shoot, you pop a cap.
I haven’t ever thought it had any more profound origins than that…