Obviously not the ones making the “why are you $X” comments in this case though.
Obviously it's possible for non-experts to post authoritative-sounding answers on questions that they don't really understand, but I think that is a different category of problem from the "XY-problem" style answers.
But the answer to the question "How to do X?" really shouldn't include more than a passing reference to "Here's how to do Y." If X is impossible, then that is of course the answer.
And as others have indicated, the most frustrating scenario that happens over and over is that once the "How to do X" question is asked, you can never get an answer to that question if the original poster relents and agrees that what they really need is an answer to "how to do Y?".
Would you be willing to be responsible for the fallout of answering that question any other way besides "use parameterized queries instead"? Do you really think that should only be mentioned as a passing reference?
And the passing reference to the potential misuse here can be a big bold statement at the top of your answer.
And since every question about such things get auto corrected to use parameters (which doesn't help, since it's something else entirely), You have millions of buggy self glued sql queries allover code bases. (but hey most of them are using parameters, so yay - progress)
If there truly is a circumstance which makes X the right solution, then that might warrant a new question being posted with the additional context to make that so. But I suspect it's much more often the case that the asker is simply being stubborn and doesn't want to change their plans.