Nostrils accomplish two things:
- They filter out impurities and particles in the air. Thanks to the mucous membrane and hairs which act as a maze for the air to pass through. Snot is later drawn in to be digested or expelled.
- They identify said particles for us to smell. Since they catch particles so easily they are the best place for sensory organs. The jacobson's organ (primary organ for chemoreception) is an essential survival tool for most animals.
Now the question is why a creature have multiple sets of nostrils?
In arid or cold conditions animals opt to have larger noses instead, which is where the difficulty lies in this question.