I'd separate the encounters into two (or three) categories.
One is when a salesperson approaches you, or you ask somebody you do not know for a hand for a second, and they make an incorrect assumption of the situation. You could be there with a buddy, and they assume you are a couple; or they could assume that because you look a certain way, you don't know much about a specific field. While this is annoying/irritating, it means no harm, because the assumption was made without any proper information, only appearance, and the underlying intent is just to help.
(Even as a male, I do encounter this quite often personally. As a coping mechanism, I usually describe my problem with a clear indicator of my knowledge level in the subject embedded. For example, if I am looking for a specific electronic component, I might say I need it for the first PCB I've designed myself, or that I do not yet have a hot-air soldering station, only a temperature-controlled one that I'm quite comfortable with; or if I am looking for a specific type of paint, I might mention paints and varnishes I've successfully used in the past. I describe the problem first; include clear signs of my knowledge level, or even state it outright; and only then describe the solution I think should work and need help with, and listen to their suggestions. This seems to work for me, although I do feel I'm TMI!ing all the time.)
The other is when a person ignores what you say, and instead go solely based on their assumptions.
That is absolutely infuriating, and I've encountered that personally from all sorts of people, from doctors to winos on the street. Not too often, though. There seem to be two groups of such people: the truly stupid ones (who simply cannot fathom the situation, and simply go by their instincts, without a rational thought ever crossing their mind) who I don't think can be really categorized as sentient beings; and those who are completely uninsterested in you, your problem, or helping you in any way, but need something out of you, even if it is just for you to leave. If they are paid to help you, then they belong to the group of people who should be fired, and you should feel free to completely avoid, ignore, and denigrate them as much as you like. The two groups overlap when people are overworked or just too tired to function well, in which case be gentle.
I do not want the aforementioned categories mixed, because I do feel the first category is basically innocent (even if bigoted or prejudiced or presumptive, it is not like they knew anything about me except my appearance); the stupid and the overworked cannot help themselves; and only the self-centered ones do deserve hard push-back on their behaviour.