The 'official' way is indeed to convert the comment into an answer, see How to end the "unanswered" status of really solved questions in the comments and Solved by comment -> how to flag. The person writing the answer can be either the original commenter, or the asker (along the lines of 'from the comment of @johnsmith I found the answer and it is as follows [...]), or a third person, that may or may not use the Community Wiki feature. All three options happen regularly.
However, on TeX.SE it is common that short answers are posted as comments, where the commenter feels that their solution is too simple for a full answer. See Why do people answer in comments? for some background on this practise - the main reasons are that it is untested, or that it is a near-duplicate (see question X but change Y into Z), or that it is a very small modification to the code of the OP (remove \par
in the third line). In this case the commenter does not always want to write an actual answer, for the same reason that they originally chose to write the comment.
These questions are regularly closed as "solved in comments", as a way to mark them as being resolved. This is contrary to the Stack Exchange model of "comments are for clarifications and answers are for answers", but it works well for us, mainly because these comment solutions are usually correct and therefore answer voting is not necessary to determine quality, as is needed on other SE sites. This kind of comments can effectively be regarded as permanent - our moderators will not remove comments providing an answer, and commenters also generally do not remove their own comment if it has the answer.
It may happen that a question is closed too early and the commenter actually would have been interested in writing an answer. However, this does not happen very often I think, and in any case if the commenter wanted to write an answer then they should have done so in the first place. Such a closure does not mean that your question is off-topic. In that case (most) close voters will type "is off-topic" or "is not related to LaTeX" in the custom close reason box, instead of "solved in comments". This is unfortunately not shown in the closure box at the top of the question, but it is visible in the auto-generated closure comment below the question.