Blackpowder is an explosive. it will explode if in a fire.
Smokeless powder is not. It burns fiercely if in a fire.
Storing blackpowder in a box is so the occupants have time to vacate the premises before it explodes if there is a fire.
When the BP box was first introduced, like you, I thought it would be a potential bomb. I wrote to the HSE, Explosives, to express my concern. They explained the reason to me and then it made sense. If I recall correctly in their tests it took approximately 18 minutes for the fire to ignite the blackpowder. (Ample time to vacate the premises). The time, obviously, is dependent on the fierceness of the fire in relation to the location of the BP.