It comes from a longstanding and growing meme, probably over 10 years old now. There is a certain type of guy who people pejoratively call "neckbeards," referring to their poorly kept scruffy beards. They're usually overweight, have poor hygiene, and are generally horribly awkward and possibly misogynistic toward women. Some of them like to wear fedoras because they see the hat as being classy, and they see themselves as being some sort of refined gentleman because they have the apparent class and style to wear a fedora. The way some of them behave toward women has seen them mockingly labeled as "Nice Guys" because many of them complain about how no girls will go for them and put them in the friend zone even though they're a nice guy... which in reality means they do nice things for girls out of the expectation that it'll make the girl date and/or fuck them and they get butthurt when that doesn't happen. Part of the Nice Guy package is trying to treat women extremely nicely, and when you mix in the fedora lovers who think old = classy you get people unironically using the term "m'lady" to refer to a woman.I don't really get what's up with fedoras and 'm'ladies'.