I think it's a combination of things. 1- Although we don't always remember things consciously, all of our memories are stored in our brains, we simply remember certain things consciously. I believe when we do/say/see something that we have before we may not immediately remember it but the memory is coming to the surface at that moment and we can't, at that moment process where or when this took place.
2 - I also believe all of us have psychic ability, not all of us may use it though. We may have dreamt of that moment previously or we saw it happening in our unconscious prior to it happening and we are realizing that during out déjà vulgar moment.
3 - I believe most of us have lived previous lives. We may have experienced a similar situation in a previous life, and that moment is triggering a memory.