In ancient Egypt this symbol: was represented by water and was called “mayim”.
After some time during the Proto-Sinaitic period the symbol changed to which was called “mem”.
The Phoenicians changed it by putting a curved line at the end.
Paleo-Hebrews didn’t change it much they just made it curved.
Aramaic people made it go a bit weird, they changed the curved lines for a line.
The Greeks did the same as the Phoenicians but they made it straight and they turned it around.
The Romans made the last stick go to the bottom, and that made our actual M.