A considerable portion of the questions asked on Stack Overflow are beginner questions. Often this makes the answerers considerably prone to underestimating the asker's capacity to understand their own problem, if not outright hostile. This, however, can yield a lot of false positives, because it escapes the realm of beginner questions and finds it way to potentially every question.
As an (abstract) example of this, consider that you ask a (non-beginner) question on how to do something and in the premises you explain that you are constrained to do it in a specific way. Then, someone gives you an "answer" that mostly informs you that "you're doing it wrong", while ignoring (implicitly or explicitly) the premises and, therefore, not really addressing the question that you actually asked.
Sometimes, answering patterns like the above are valid and helpful, because you may be in a domain where you're not sure of what you're doing and such responses will help steer you to the correct path. Other times, however, the pattern becomes obnoxious, because it feels like you have to include some kind of "street cred" in every question to persuade people that you're not completely clueless, that you're asking this specific question for a reason and/or that it's not cool for them to come off as rude.
Obviously, the first thing we can do, as askers, is phrase our questions in such a way that as many answerers as possible will get that we know what we're doing (if that's indeed the case). However, after we've made our best (to make what exactly we're asking as clear as possible) - if the above pattern still emerges, what's the best way to deal with it, in terms of commenting, voting and accepting?
In other words, consider being the asker in what's wrongly perceived as an XY problem:
Say that (for whatever reason) you actually want to learn about your attempted solution (which sometimes may be more general, educational and useful to you and visitors) and not about the underlying problem that you have (or, worse, the problem that the answerer decides that you have). How can you achieve that? How to deal with answers that, despite your explanations, still deal with the latter?