Muscle memory and playing by ear are very much related. You probably don't want to just memorize songs or chord progressions because that won't help you in the long run. Instead, try to figure out songs by ear. This is the main exercise, but it gets easier with every song you work on because you're making a link with what you hear to where your fingers go.
You need to familiarize yourself with the sounds and develop muscle memory. Before you press a certain note you'll already know what it's supposed to sound like in your head. That way you can play anything you hear instantly or jam alongside with someone as they play. It's the same as whistling and humming. But in order to do this you should build a solid foundation first:
Practice scales / arpeggios. Do this alongside figuring songs out by ear, or you'll just get bored. The reason for practicing scales is mainly just knowing what the pattern is (what black/white notes need to be pressed for that given key). Everything you hear around you on a day-to-day basis is in a different key. You need to get to the point where the patterns of scales and their associated diatonic chords are ingrained in your head. What makes it easy is that all major keys work exactly the same, they're just higher/lower pitches of the same sound of "do re mi fa so la ti do". and minor is just a mode of major, so first learn major and then you just shift it to get to minor. you'll see what I mean later.
Figure out songs by ear. This is the most important part. Start with nursery rhymes / baby songs as those are the easiest. So "row row row your boat" or "twinkle twinkle little star" or whatever other songs you've heard in your childhood, "amazing grace", etc. Don't use sheet music for these. Just try to pick them out by ear. Especially the melody. Once you've found the melody try to figure out what scale you're in based on the practice you did with 1.
Add chords to the nursery rhymes. You'll find that the I IV V chords (primary triads) are the most often used followed by the vi ii and iii chords. (assuming we're talking about a song in the Major key). The roman numerals that I just wrote are the diatonic chords of the scales, if you don't know what those are and how to find them from the scales, do some research. You'll be playing those chords in your left hand, whereas the melody is in your right hand.
Try to play the nursery rhyme in any key. You should eventually be able to play "Row row row your boat" for example, in all 12 major keys both the melody and its chords.
You can transpose any major song to the key of C major to make it easier for you to experiment with what chords sound best. So know how to play all the nursery rhymes in the key of C major for example. You can then practice with songs in minor keys.
The nursery rhymes / practicing scales/arpeggios then becomes the "foundation" of your muscle memory and ear training. Keep adding more and more songs. Just keep a piece of paper with all the songs you've figured out by ear. The more you do this you'll find that you don't even need to keep a piece of paper anymore because you'll be able to play whatever you hear instantly.
You'll then be surprised that pop songs aren't that much harder than nursery rhymes. It's pretty much all the same. You just add chords to melodies in whatever key you're in. By practicing playing songs by ear, the more you'll do it, you'll develop muscle memory to the point where your fingers will go directly to what you are hearing in your head both for melody and harmony.