The letter מ denotes the phoneme /m/ (like the sound of ⟨m⟩ in the English word mess).
The letter מ has a distinct special form used at the ends of words, namely ם. This form is called mem sofit or (in English) final mem.
For information about מ as a preposition meaning roughly “from”, see מ־.
For information about מ as a sort of prefix in the present tense and present participle of pi'él, pu'ál, hif'íl, huf'ál, and hitpa'él verbs, see Appendix:Hebrew verbs.
For information about ם as a suffix meaning roughly “them”, which is one form of the third-person masculine plural personal pronoun, see ־ם.