I read at several places that "don't mention it" is equal to "you're welcome". But for me, the word means something like "don't go around talking about this to anyone". So what is the real meaning of the phrase and how does it fit in as a response to "thank you"?
It doesn't at all mean "don't go around talking about this to anyone." It is in fact much closer to "you're welcome."
When you are telling someone "don't mention it", what you are telling them not to mention is the 'thank you' itself -- you are saying "Your thanks isn't necessary. I was glad to do it, so you didn't need to mention your thanks."
(Note: This is just an expression. It's definitely a good idea to express thanks when someone does something for you; "don't mention it" really just means "you're welcome; glad to do it.")
"Don't mention it", along with "please", "thank you", "you're welcome", "good morning", "how do you do", "lovely weather we're having", "we must have lunch some time" and many many more are phatic expressions. They don't mean anything, and are not meant to mean anything. They exist solely to oil the social wheels.
The fact they don't mean anything doesn't mean it is all right to omit them, however.
Other phrases that carry similar meaning are "think nothing of it," "it's nothing," "not at all," and "no problem." Likewise, a common replacement for the French "merci bien" (thank you very much) is "de rien" (it's nothing).
The meaning behind all these phrases is that the thing done was so small or so little trouble that no gratitude is required.
The expression don't mention it is in the meaning as that's too little to mention.
There are similar thank you responses in other languages, like the German nights zu danken (too little to thank for) or Swedish det var så lite så (that was so little).
Common in these expressions is to belittle ones own deed, which should not really be taken literally as that would also belittle the gratitude, but rather in the sense of I'm glad that such little effort on my part could help you so much.
This is what Sheldon Cooper would have said -
it's a non optional social convention.