IMO memorization is the successful integration of the many different perspectives we can view music. Lelle has put together a good list.
Here are some of the different "memories" you can learn to develop:
* Muscle memory - the most basic and unreliable one IMO. Comes with repeating your piece over and over until playing the notes is automatic.
* Aural memory - remembering how the piece goes, helping you know or at least make an educated guess on what key to press based on what sounds are supposed to come next. Improves as your ear training improves. Easier if you have perfect pitch.
* Visual memory - a big one for me. Involves remembering how it looks when my hands are playing the right chords or passages. You kind of look at the keyboard and know where and how to place your hands next.
* Sheet music memory - remembering how the score looks so that you can recall the score, read and play it from your mind, so to speak.
* Music theory memory - this one is huge and can get quite advanced. Even if you just start getting into the basics it can help you a lot. Involves a number of subskills such as
** Basic chords and scales - remembering everything you plays in terms of what basic chords and scales are used, and any deviations therefrom. Helps you remember big chunks of music because a bar suddenly becomes "A c major scale in sixteenths for three beats" rather than 12 individual keys presses to remember, or "an A flat major arpeggio with a B natural thrown in along the way".
** Harmonic functions and common chord progressions - helps you remember longer sequences or make educated guesses on what to play next because you know all the common patterns and have identified which one is being used at a given moment. So even if you have forgotten the exact notes, if you know that "here comes the dominant followed by the tonic in A flat major" you can play something that's reasonable and at least continue playing without interruption if you forget the exact notes. And knowing that "this is this common chord progression realized in this particular way" helps a lot with remembering a passage because you have a logical structure to connect what you are doing to. Everything that helps me understand something as a part of a larger pattern helps me remember it.
** Voice leading - again helps you understand and make educated guesses on why particular notes were chosen by the composer to come next in many cases.
Memorization isn't a simple data dump, and trying to cram information into one's head. Such is a path to a very frustrating and taxing experience into memorizing a piece of music. Rather, memorization is understanding the various perspectives in music, and applying this knowledge to the piece one is studying.
To take an example, try to memorize a paragraph of text in a foreign language one does not speak. One might end up stringing together a bunch of characters to do the task, difficult and laborious. Compare that to memorizing a paragraph of text in a language one does speak. In that case one can piece together words, sentences, subjects, ideas, etc. One understands the paragraph from many different perspectives, which aids memorization.
***
To memorize music better, engage with the music with the aim of gaining deeper understanding. Think about what the music looks like at the keyboard, what it feels like to touch the keys, what it sounds like. Think about how the harmony is moving, how rhythm grooves.
Practice memory recall. Start playing from random parts in the middle of the piece, not always from beginning to end. Don't be afraid of failure or memory lapses, practice them! Practice getting lost, and trying to get back up on your feet without referring to the score. Know where you want to go, at all times.
Practice improvising your way out of a memory lapse.
In your practice session, create an environment of focus and mindfulness. Eliminate all sources of distraction. Healthy memory workflows, which are resilient to the stressors of performance, are ones that embody disciplined focus, a persistent sense of awareness of where one is and where one wants to go, and the agile ability to adapt and shut out all forms distraction which attempt to derail the focus of the task. Work on getting to know the music at a deeper level rather than stuffing a bunch of data in your head. Take joy in the process of discovering more about the music you are studying, rather than stressing about the amount of data that needs to be remembered.