As noted in [this answer](https://meta.stackexchange.com/a/286804/162102), rolling back the edit is usually a reasonable response.  But if you're reluctant to do that or find yourself in an edit war with the OP, another thing you can do is to edit your answer to add something like "this answer addresses the question as of revision 4".  That should fend off some of the "what are you talking about? that wasn't the question" reactions.  I've done this with no ill effects.

Try to state it dispassionately; don't say something like "the OP keeps changing the question and I'm done trying to keep up".  You should be trying to inform readers about the context of your answer, not reprimanding the OP.

I'm talking here about an answer that was already well-developed when the question was edited.  If you post a stub in pursuit of FGITW and then the question changes a couple minutes later, you should either fix or delete your answer.  The intent of this suggestion (and I think your question) is to avoid punishing people who answered in good faith.