There are some scientific theories that explain it as a miss-timing of neural firing. In this case your brain would receive a signal and then the same signal almost instantly right after it which would cause you to think that the situation has happened before (which it has according to your brain a few microseconds before) and produce a sense of familiarity. The theories hypothesize that delayed signals coming from say one of your eyes or one of your ears could cause the miss-timing which would produce deja-vu.
As for me i am not sure where it comes from. I experience it occasionally and it is probably one of the creepiest/weirdest feelings. I’m not sure how other people experience it but to me it is like i feel like i know what is going to happen, but i can never actually predict it. And when it does happen I think “Oh, yeah. That IS what was supposed to happen next.” And the longer it goes on the more creepy it gets.