Question: Most of the time in all the Spanish speaking countries I've been in I've heard ***de nada*** as the reply to *gracias* or the equivalent of English *you're welcome* etc.

But after a while I became conscious that sometimes some people were instead saying ***por nada***.

Are they actually used in different grammatical situations? Does the *de* vs *por* depend on something in the topic of what the thanking was about?

Or is it purely up to how the speaker feels, or is one more prevalent in certain places? Or is one less formal or not condoned as official by the RAE?

Answer: 
de nada is used after Thanks - its means you're welcome - similar to the English 'it was nothing'

por nada is For Nothing. Gracias por nada. Thanks for Nothing! used rudely if someone didn't do anything for you. I would use it if someone takes up lots of your time and then doesn't follow through.
Por nada is more like saying "no problem" than "your welcome", so its a less formal response.