How are lowercase m and uppercase M used in general chemistry courses?
Lowercase m


$m$ is the official symbol for the quantity mass.
m is an SI-prefix that stands for milli ($\pu{e-3}$), for example in mg (milligram).
$m$ is sometimes uses as the symbol for molality. This is not IUPAC recommended (they recommend $b$) and leads to the confusing definition $$m_\text{solute} = n_\text{solute} / m_\text{solvent}$$ where the first $m$ is for molality and the second one for mass.


Uppercase M


$M$ is used as symbol for the quantity molar mass (dimensions mass per amount of substance).
M is an SI-prefix that stands for mega ($\pu{e6}$), for example in MW (megawatts).
M is often used as an abbreviation for mol/L, and mM for mmol/L.
$M$ is sometimes used as a symbol for the quantity molarity (dimensions are amount of substance per volume, official IUPAC name is amount of substance concentration, and official IUPAC symbol is $c$). Textbooks that follow this convention sometimes use MM or ℳ as an alternate symbol for molar mass to avoid name conflicts. Combining the quantity $M$ with the unit M gives silly statements such as: $$M = 5~\text{M}$$


Other useful information


Make sure your lowercase m and uppercase M look different when you write or type, otherwise you are confusing your readers. If you type, quantities should be italicized and units should not. That also helps to distinguish the different meanings of m.
You can't cancel m with m if they don't have the same meaning. It is fine to cancel the milli in mg/mL to obtain g/L, but not cancel $m$/mg to obtain 1/g.