Sometimes an apostrophe can make all of the difference. So it is with these words.
“Ma’am” is the correct spelling of the polite address of a woman, as in “Thank you for the change, ma’am.”
“Mam” refers to a member of a Mayan people of southwestern Guatemala or to the language they speak.