In Ch. 8 when they make the gunpowder Senku already had a bag of potassium nitrate (saltpeter) prepared which he says he prepared long in advance. Remember, before Senku and Taiju brought back the petrified Tsukasa and heard his cull the herd ramblings they had a monopoly on the cave with the nitric acid which gave Senku ample time to make the useful chemical saltpeter. Besides its use as a component of gunpowder which was certainly one of Senku's considerations potassium nitrate is a good fertilizer in case they wanted to plant some crops and one of the easier chemical oxidizers for him to make.
As to why he didn't try for a different explosive is not explicit but TNT would not have been a viable alternative for a myriad of reasons. I'm mostly reading off wikipedia for this but the first step is to nitrate toluene in the presence of nitric and sulfuric acid, while they have some nitric acid they do not obtain sulfuric acid until much later as the process for making sulfuric acid isn't something they had the tools to do. Both of those chemicals are very dangerous and they don't yet possess glassware to store them safely. TNT also started out as yellow dye, people of ages past were not really dumb and really dead though as TNT is incredibly stable in standard conditions which is one of its most important features. To detonate it you need some sort of blasting cap which is itself a small explosive and at that point you'd probably just want a different explosive. Gun cotton is similar as it can be made using plant fibers and nitric acid but is very unstable in that form and in its proper form also requires sulfuric acid. They theoretically could have made something else that involves none of sulfuric acid, oil or better containers but gunpowder is stable and powerful enough for the limited time and resources they had