Of course, this is related to Exit strategies for "chameleon questions" , as noted by TheEstablishment, but unfortunately, it's sort of useless here--since the non-dupe assumes that you can answer the new question, just that you don't want to.
It's happened to me a few times--I answer a seemingly simple question, and then the OP, on seeing my answer, clarifies the intent and makes it much more complicated.
In this case, what I do it depends upon my answer. If I gave a short answer to an exceedingly simple question, it goes down the memory hole. Actually, all short answers go down the memory hole on a change of question.
If I gave a longish answer to a not-too-complicated but hard initial question, I keep it and hat it with "this answered the original question which was blah". Usually, the post still contains some useful concepts and explanations, and while it does not answer the question, it definitely helps.
If I gave a long answer to a simple question, it really depends. I guess the checklist for keeping an answer is:
- Does it answer the question?
- If not, is it a significant step towards answering the question?
- If not, does it explain relevant concepts which may help the OP understand the situation better and/or answer the problem himself?
- If not, memory hole!
But that's just my opinion--and note that it is based on my experiences on Physics.SE--usually SO answers don't explain concepts so it may be different there.