I don't agree with this line of thinking. Helping the user at hand means you help at least one person, and probably others which might have the same problem. This is the purpose of the site! The OP is supposed to select one of the answers as "accepted", if the answer solved their problem.
You suggest answering "the wrong question" would help more users in the future. I don't see why that would be likely.
Again, you're assuming the question is "wrong". But how likely is it that every single person who asks that question is wrong? With your line of thinking you help the OP and anyone who gets in the exact same situation as the OP but no one who actually needs the answer to the question that was asked.
If you're worried about it then just answer exactly what was ask and follow your strategy. But please don't simply do your strategy because it's a real pain for those of us who end up having to move off the beaten path from time to time.
I should not have used the word "wrong", of course someone would nitpick that. I mean the Y in an XY question.
My point is just you should try help the person at hand with their actual problem, the X, and then clarify the question title to reflect the problem they need help with. It is easy to see if an answer have solved the actual problem - the OP selects the answer as "accepted".
If another person have a different problem which happen to be Y they will ask that as a question and get help for that. Everybody is happy.
I get really miffed when I see someone answering the literal question even when it is clear that the OP have a different problem and is just not knowledgeable enough to put it in the technically correct terms. I guess it is an effect of the education system when people think it is better to provide a useless but technically correct answer, than actually help people who have a problem.
Answering both X and Y is fine of course, and probably the preferred.
>and then clarify the question title to reflect the problem they need help with.
How many times have you seen that happen? Further that only occurs in an XY situation where the question was wrong. I've been hit by cases where the answer was "don't do that because it's bad". Well, I know that and I know why it's bad but I also know that I have to do it anyway. What now? You couldn't change the question in that case because they asked what they meant, they were just told that they were wrong (and they were).
>I get really miffed when I see someone answering the literal question even when it is clear that the OP have a different problem
And I get just as miffed when they don't because of all the times I get burned by people behaving as you want and then I can't get that same answer answered and have to go through even more pain (it was painful enough to be forced into the situation) to figure it out for myself. I have basically no karma on SO because when I get some I use it to vote down such people.
>Answering both X and Y is fine of course, and probably the preferred.
Good point. If they really asked what they want (it wasn't an XY question), I don't think "don't do that because it is bad" should be accepted as an answer, since it isn't, and it doesn't help.
It is the OP which decides what it the accepted answer though, but the community should not upvote unhelpful answers.
You suggest answering "the wrong question" would help more users in the future. I don't see why that would be likely.
N could be less than 1