Sir Is used as a polite or respectful way of addressing a man, especially one in a position of authority
Ma’am Is a term of respectful or polite address used for a woman.
However, whenever I hear this directed towards another human at a retail, restaurant, or other place of business during a customer complaint, it always has the connotation of @$$h0le or B!tch. It’s never used with endearment but rather as derogatory. It’s overused with emphasis that you are not getting what you want no matter how reasonable you are being. To be blunt it’s a power trip for the person using it. It’s like calling your dog a stupid idiot, but using a nice voice so he still wags his tail and licks his chops with excitement.