The Hobbit has a narrator, who speaks from a "modern" perspective. It describes in the beginning how Hobbits are few now and avoid the tall folk, all that. So I'm fairly sure this is the narrator giving a frame of reference, rather than Bilbo knowing the smell.
Later it is also said that Orcs are cunning inventors of things that kill, including things that kill a lot of people at once.
Not only that, but in LoTR Helms Deeps outer wall is blown up with gun powder or similar.
I thought the Hobbit was meant to be written by Bilbo so a modern narrator explains it.
I knew there were things like explosives and fireworks, but unless guns are a common use, calling black powder "gunpowder" is weird so I wouldn't expect middle earth to have that word.