There is a mind boggling theory for this. If you are an avid reader of EVA Geeks you would enjoy it very much. So here is my small take on it.
Rei appears with the same uniform in the End of Evangelion standing on a sea of LCL. Here is the scene:
Shinji, when he first sees Rei at Nerv, recognizes her and makes a connection to the girl in the school uniform. So he is not hallucinating when he sees the image of Rei.
At this point there are a few theories:
The Rei which is seen could be Eva Unit 01 which is trying to contact his mind.
Another theory is that Shinji has mental visions of Rei in episodes 16 and 20 which could be Rei herself contacting Shinji telepathically.
A nice theory would be that Rei has the DNA of Yui Ikari and Lilith. So essentially, it's two mothers watching over their sons: namely, Yui looking after her son Shinji in the first episode and Lilith, who is the mother of Lilin, or all mankind, looking after her sons / daughters (let's not go on that path) in the End of Evangelion (picture above).
Mind blowing theory:
I swear this is one of the mind blowing theories I have read about Evangelion. But it gives reason to your question.
In episode 23 Ritsuko shows Rei's room. If you notice the wall it has the words "Top, Bottom, Strangeness". This presumably is put there to show Rei's powers or nature. In quantum physics these three represent a sub atomic particle called the quark. The six types of quarks are: up, down, charm, strange, top, and bottom. As you can see, three of the quarks are listed in Rei's room. The way it is related is that quarks defy classical physics. They can be at two places at once. In End of Evangelion, Rei is seen everywhere. At the sub-atomic level the particles do not follow the laws of physics, so much that they can create effect without cause, or they can reach their destination before starting their journey. So this could give you reason why she could be at two places at once or show up as an image at the beginning and at the end.
P.S.: I did not come up with connecting the quark theory, but I did realise the writing on the wall meant that Rei had a connection to quarks or just that she likes quantum mechanics a lot (like me :D). But EVA Geeks had this connection posted and credits to them for this mind boggling theory.
Source at EVA Geeks: Theory and Analysis: Rei's Ghostly Appearances and Quantum Mechanics.