You're assuming a basic simplification of muscle memory for melody, but that's actually a bit more complex: it's not just about moving fingers on the right or the left, you also need to know the interval, which may cause switching black/white keys.
For instance, a basic movement that plays a minor third may start with the right hand thumb and either use the index or middle finger for the second note depending on where each note is: for white/white and black/black keys, you may prefer the middle finger, while you could opt for the index when switching "key colors".
In fact, that choice may change depending on your hands: the proportion between your hand bones, how "thick" your fingers are, and how much your technique is developed.
The position of those notes related to your body is also important: for example, continuously switching between two notes a fifth apart may require you to use different fingers depending on their pitch.
Try to alternate C/G with your right hand on the higher octave of the piano, and then do the same two octaves below the middle C: you may find out that it would be easier to do that with thumb+ring (or middle) fingers in the former case, and probably index+pinkie in the latter.
Now do the opposite with your left hand.
The situation can only become more complex when dealing with chords and progressions.
Even if similar inversions and chord relations may have similar hand/finger movements, progressions involve much more complex aspects. The same chord type may use different fingering depending on the fundamental. And the same progression may require different fingering too.
Considering the above example, you may need to use the middle finger for the third degree (while you'd normally use the index for that chord), because in the next chord it would make more sense to switch to the index for the second note of that chord.
Another progression may require you to use the index for the first note, instead of the thumb.
The actual length and tempo of the progression may cause different fingerings too: a basic chord switch may be easier when dealt with as a stand-alone progression, but it could create issues for the next change. When playing at slow tempo, you may be able to use more comfortable positions, but if you need to play faster, you may require a smarter fingering.
All this means that you need a higher abstraction layer that considers both the progression and the "finger layout" for a specific chord based on its fundamental (or inversion). And that can only be achieved by practising progressions at different keys.
At some point, your brain will start to learn a deeper level of "muscle memory", probably split in two types:
- a simpler one, used for common progressions that you practised enough;
- a more complex one, that eventually intervenes when the above fails (because you don't have a basic muscle memory for that progression), based on the sum of abstractions related to degree/chord relations, key positions, etc.;
As time goes by, more cases of the second will become part of the first.
Simply put, the "muscle memory" you're referring about is a very simplistic sequence of movements based on extremely simple changes: for instance, a specific virtuoso passage that fundamentally is a "list" of well defined and precise movements.
Chord progressions are not like this.
So, I believe that the only proper answer to your question is: practice, and a lot.