Some people have a “photographic memory” and can see in their mind the music as printed on the paper. Some people rely on aural memory (hearing it in one’s imagination). There is also muscular memory (the fingers "knowing" what to do). Probably most people use some combination of all these methods.