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.