Ma’am is the colloquial shortening of madam, by replacing the “d” with an apostrophe. Madam (madame in reference to foreign women) was once a title of respect for a woman of rank. It is now the respectful form of address to give a married woman. It came from the French “ma dame,” which translates to “my lady.”
Madam also a female owner or manager of a brothel, but that definition didn’t come around until 1871.
You and any of your readers interested in etymology may want to peruse my blog, which deals with the origins of English and Spanish words.
Interesting. I didn’t know any of this.