We use the term 'go off' about a change of state: something that happens just once. At one moment the gun contains powder and a bullet: the next it contains only smoke. The same is true of bombs, fireworks, foodstuffs (albeit rather slower). For an alarm clock, it descibes the moment when the clock starts ringing. If a person goes off something, it means that they stop liking something... a state change from liking to not.
Because it is a state change, it works for a single shot from a rifle, pistol or shotgun, but the term does not fit comfortably with the continuous discharge of an automatic weapon.
Gunfire is a continuous activity and so, like the automatic weapon, it doesn't sit naturally with going off.... unless, like the alarm clock, you choose to regard it as the moment that the gunfire started. So, gunfire going off is understandable, and it is used, but it does not sound natural.
An explosion is already a state change: it sounds wrong to talk about a state change of a state change. An explosion going off does occur, but again it does not sound natural.