But the answerers cannot know that. So adding a small snippet of what have been tried, or why X specific is what's needed is a good idea to steer the conversation in the correct direction.
I, for one, never use places like SO anymore because everyone just wants to pretend you really want Y, because that's an answer they know.
However, it's hard to tell if the quality has actually changed, or whether it's just more geared towards novice programmers and I'm just not asking the type of questions that get help on the platform anymore.
Although tbh I quite often want the opposite, so I add "Alternative solutions/workarounds welcome" or "I don't see how I can avoid doing X but maybe..."
Listing all of the things you don't want to do would not only take up more words and effort than the question about what you do want to do, but is hopeless. Somebody who doesn't know the answer to your question but still wants to comment will find something that you were unaware you didn't want to do.
It's better just to answer questions directly, and then when somebody uses that solution and it doesn't get them closer to the solution to their real problem, they'll ask a better question.
And bad solutions can still "solve" problems with horrible trade-offs, so instead of searching again for a better solution people may just employ the worse one unaware of the better possibilities, consequences be damned.
For instance, if it's a semi-vague question just pointing in the direction of a solution, then I think it's fair to question the motivation of the poster.
But if it's a very precise question about how to accomplish something specific, I think the burden should be on the person answering to add the clause: "you can do X, but its generally not considered a good idea because Y".
Honestly if you can't answer the original question, I get the impression you're just trying to be a smarty-pants and show off some domain knowledge you have which is related to the task at hand.
But people look for already asked questions by searching for them. And I don't think that there are many things that are more frustrating, then finding a questions that describes your problem X perfectly and it has only answers to Y.
Maybe the asker really would be best suited with X due to some contrived circumstance, but is that true of everyone else who finds the thread too? Probably not.
I.e. "you can do X to achieve your goal, but you probably shouldn't because Y".
I just don't see how it's helpful or contributive to participate in the discussion if you don't actually know the answer.