Hi dora,
There are basically four kinds of memory. The one that jerryjay describes so well above is intellectual or analytical memory. It is studying the structure of the score away from the piano to discern themes, variations, patterns, modulations, important harmonies, special "landmarks" (in case you lose your way and need to get to a familiar point to preserve continuity), etc. This method of memorizing is very useful for people who have studied form and analysis, harmony, counterpoint, and music theory; but it is not limited to them. There are many structural aspects that are readily apparent to the most casual pianist that can serve in the same way as memory aids. So it has wide applicability.
The second kind of memory is tactile memory, sometimes called digital memory. From this approach, the pianist becomes accustomed to the "feel" of playing note groups, chords, passages, phrases, accents, etc. of a piece. The music gets "into the fingers" as they say. This is probably the most common kind of memory, but is also the most dangerous. It is generally the first memory device to fail and flee the scene when a problem develops in performance.
The third kind of memory is visual memory. This, I believe can be considered two ways. The first kind is the so-called "photographic memory", whereby the person can close his/her eyes and literally see the score perfectly as if the music were open on the piano's music desk. The only problem with that is that very few are born with that extraordinary ability. A more common kind of visual memory though is looking at the keys while one plays, and over time associates the stream of music with the simultaneous visual aspect of the piano keys being depressed, thereby forming memorable motions and patterns in the moment on the keyboard. You'd be surprised in talking to other pianists how many of them say they are very conscious of this. Did you ever watch, for example, a video of Jorge Bolet playing? He would constantly keep his eyes glued to the keyboard. I believe that's what he was doing--using that particular form of visual memory.
The fouth kind is aural or auditory memory. This involves memorizing from the sound of the music through practicing and playing. This requires no perfect pitch, as not everyone has perfect pitch, just relative pitch will suffice. For anyone who plays well by ear, the aural approach to memorizing comes naturally.
Now, the important point. The more of the four approaches you can combine and bring to bear, the more secure your memory will be. There is no one way to do this. It depends on your own abilities and tendencies. In my own case, for instance, I relied on both tactile and aural memory. I played in countless student recitals, not only my teacher's, but in other regional recitals as well, plus solo recitals as well as at special events and being a finalist in a competion in Boston. I have to say, never once did I suffer a memory slip. BUT, that particular combination might not serve everyone as well. Someone else might be more comfortable with the visual and analytical methods, or whatever.
A note on focus or staying focused: The culprit of losing focus is usually mental distraction. For example, while playing, you think of a spot a half-page ahead that is so hard to execute. Or, something pops into your mind--something that you have to do later perhaps--that distracts you from the immediate task. You may have noticed this many times when practicing. While doing some repetitions, you may hear an odd noise outdoors, or suddenly recall you need to call someone that night, or you get a mental flash of the next piece to practice, etc. Next thing you know, within two seconds the practice repetition suffers an error and falls apart. Similar things can happen too in performance unless you're careful. So, you have to concentrate on concentrating.
Finally, another note, a sad one I guess. The older we get, it becomes progressively more difficult to memorize, and reaches a point where it is nearly impossible, necessitating always reading from the scores. This is a natural aging process and is true for a great many people. Even an artist as great as Richter in his late years had the scores open on the music desk while performing. He didn't want to take a chance. Oddly, older people can often play the very first piece they ever learned, or pieces from teenage years from memory. But they might not be able to play by memory something learned just a month ago.
I hope this helps.