Answers are for (valid) questions, comments are for commentary
First, carefully consider whether the question meets the site's standards, and whether the comment actually constitutes an answer.
Sometimes, people use comments instead of writing a proper answer because they don't think it's appropriate to write a proper answer. There are a variety of possible reasons for this, some better than others. Keep in mind that any upvoted answer will prevent a closed question from being automatically deleted, indefinitely.
If the problem in the question is caused by a typo, politely pointing out the typo in the comments is more likely to leave a positive impression of the site than a silent closure. Either way the question should not be given an answer, but why not take a moment to be helpful?
Similar reasoning applies if the problem is a result of failing to apply logical reasoning to what the asker already knows. Before posting a question, everyone is expected to look for solutions, attempt to debug code to isolate the problem, try to create a [mre]minimal reproducible example when debugging, analyze complex problems to find a specific sticking point, figure out clear and unambiguous specifications for the how-to questions, consider corner cases, etc. etc. When this has not been done, generally the result is a question that either "was resolved in a way that is unlikely to help others", or needs debugging details. In other words, a question that should be closed.
If the question is asking about a complex task that has an obvious and natural sequence of steps to follow (in particular, if it is a homework assignment with an explicit bullet-point list of tasks), someone might comment to explain what those steps are. This doesn't really answer the questionThis doesn't really answer the question (there probably isn't enough detail on each step, within 600 characters), and the question shouldn't be answered (since "needs more focus" is an explicit reason for closure).
On the other hand, sometimes comments are used because the commenter thinks the answer is trivial. This does not invalidate questions. We don't care about the difficulty of questions, or the simplicity of their solutions, and nominally we don't even care if the documentation includes an up-front tutorial that directly gives the answer. The purpose of the site is to function as a repository of information, in Q&A format. This is, to my understanding, what's meant by "every question about programming" in the tour.
If there's a validvalid question and you know how to answer it, you should answer ityou should answer it - regardless of how you know how to answer it. If your answer comes entirely from a comment, give credit properly, and format the comment's information properly as an answer. If your answer is inspired or informed by someone else's comment, give credit by quoting the comment in your answer, and crediting the author. After thatIn either case, please flag the comment as "no longer needed"then flag the comment as "no longer needed", as it has served its purpose. Comments are not intended to be long-lasting on Stack Overflow, as this is not a discussion forum.
If there is comment discussion that doesn't answer the question, but prompted an understanding of the question that makes it answerable, then write your answer, and if necessary, edit the question (or propose an edit) so that it reflects the understanding that was gained from that comment exchange.