The Q&A format of Stack Overflow is quite clear on this: a user posts a question about a specific programming problem, and other users (or even the OP themself) answers that question. Ignoring the question and answering some other question posed in a comment, even if it's related to the actual question, is inappropriate.
You could point this out, politely, in a comment on their answer. If the user disagrees, I would suggest backing off, as prolonged arguments tend not to go well for anyone involved.
What you can do for the answer itself is the usual:
Leave a comment pointing out that it doesn't answer the question (you've already done this if you've tried educating the OP, so don't bother leaving an additional comment that says the same thing).
Downvote the answer as a signal to other users that there are issues with the answer.
Vote to delete the answer if you have the privilege to do so.
Ask for help in a chat room that focuses on moderating content, such as SOCVR. Please make sure to read the FAQ first so that you follow the room rules.
Do not raise a NAA flag. The answer may be answering the wrong question, but that would require actually reading the question and/or comments, and that disqualifies it from being NAA flaggable.
You could raise a custom flag instead, and explain clearly that the answer should be deleted as it doesn't answer the question. This may, or may not, result in the answer being deleted. An answer to a comment may be tangentially related to the question, and could require an SME to judge its relevance. The moderator handling the flag might not be able to make that call, and since moderator deletions are binding, they are (very understandably) reluctant to do so unless the post is indisputably delete-worthy.