I totally do have a similar problem, but I have pinned down at least some of the contributing factors in my case...
My hearing is not great as a result of exposure to VERY loud music when I was younger. I mean my head in the PA cabs at Motorhead and AC/DC gigs. Stupid boy. I have difficulty filtering sound - such as conversation from pub background noise and my own singing from the music around me.
Due to being self-conscious, when I do sing, I sing very quietly. That means that I make the problem of being unable to hear myself worse. What I also find that my adherence to pitch is poor when I sing in that inhibited way. My vocal chords deliver better, more accurate pitch when I give it some welly and push out more volume - not shouting or straining, just singing up to a confident volume.
From what you say it seems that your perception of pitch and tune may be fine. Are you sure you're not just singing a counter-melody or a harmony to the main melody? I do that very often almost without thinking. It could be down to conditioning. Training your ear to separate out and recognise different musical parts may be causing your mind to wander onto alternative parts other than the main melody, and your voice could be following! The dancing thing you describe also suggests that this could be possible.
I'd suggest finding some recordings of single, solo melody instruments with no backing, so the melody is all that you hear in the recording (unaccompanied solo vocals are also perfect). Try singing along with those to see if you can remain on pitch when there is no harmonic distraction.