0
I had always heard/read/thought that it was just to reiterate the fact that, like Grady, Jack had been at the Overlook before, in another lifetime. It's not part of the Stephen King novel, it's one of Kubrick's little "let's mess with the audience's head" additions. I don't think it's really supposed to be explained or to make sense other than just making you think that maybe Jack's soul was connected to the Overlook enough so that he kept being pulled there in different reincarnations. Sort of makes sense (if you look at it from a Kubrick-esque point of view).