I could not agree more with the sentiment of this question!
As to why do people do it? It can't be laziness, because it takes equal effort to type the text and click the button.
I think it is either fear of downvotes or myopia (short sightedness):
Commenters may feel that their answer is too simple, lacking in depth, or perhaps it is untested and they don't want to risk their post being downvoted.
Commenters believe that the question is so "weak / under-researched" that it doesn't merit a "real answer".
Commenters may have the false belief that there are only two people involved in the interaction -- the asker and them. The truth is StackExchange sites are amazing resources for a growing population of researchers that is destined live on for many, many years. The pairs of eyes that hit a page are NEVER only 2.
What are the possible consequences?
Misinformation
Votes on comments only go up. So it is possible that less scrupulous users will naively upvote a commented solution which may be sub-optimal or even wrong. This may, tragically, snowball as more naive users continue to upvote the comment while users "in-the-know" are powerless to reduce the vote tally.
Premature Abandonment
Commenting answers can lead to premature question abandonment. I have seen this more than once (I won't say "a hundred times" because there is always someone who will say "show me 100 hyperlinks"). It could be: a question is asked, an answer is commented that fixes the issue, then other volunteers post answers as answers, but the OP is long gone and the others who posted answers have no way of being rewarded for their thoughtful effort. Boo.
Focal Point Disturbance
By design, solutions are to be posted as answers. Most readers know to review (at least) the top answers while researching to find the best solution and understand how/why they are appropriate. When researchers notice solutions in the comments, they need to spend (waste) time reading the comments to glean the additional solutions (which typically lack explanation) and compare the collection. Sometimes the comment thread is so long that it is collapsed and must be expanded to view which is a further hassle.
Rewarding Bad Questions
A fair percentage of volunteers want to be helpful. When some volunteers see that a basic question is asked (so basic that it can be solved with just a few keyboard strokes), they just jot down the solution as a comment. They want to help the asker, but the solution is so basic it is hard to add an explanation. When this happens, it would be better to downvote the question (if it is under-researched) and find a duplicate to close with (if available), perhaps post a link to the manual/documentation, and advise the asker to put forth more effort before posting. Generally, with these scenarios, the "greater good" is to not provide direct solutions, but to encourage the asker to "raise their game". Providing quick, commented solutions to these types of questions will teach the asker to return to the site and use it like a crutch at the first whiff of hardship (rather than search, research, and RTM) -- this chews up volunteers' attention/time which is better spent on more deserving questions.
Bad Role Modeling
There are site-culture ramifications too. When new users see veteran users posting solutions as comments, they assume it is okay. This perpetuates a problem that site designers explicitly ask not to be done.
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What do I see too often on StackOverflow?
Regex Pattern Droppers
I like to swim in the regex waters, and frequently I see people going to the trouble of generating a regex pattern demo link and dropping it as a comment. These are seldom the most refined patterns. They mean to help, but they are going to no trouble to produce a high quality pattern. This behavior ends up cluttering the page, and future researchers will have to click on these commented links to find out if they are any good or not. If they were posted as answers, there could be upvotes, downvotes, and comments on them which would make things pretty clear and fair.
One-function Droppers
Sometimes I see a snappy echo explode(',',$string);
comment. These types of comments steal the thunder from other volunteers that take the time to post a fully explained answer. A fraction of these occurrences are used by FGITW users who try to prove that "they thought of the solution first". They chuck the solution as a comment, then feverishly type away at an answer to form a 1-2 punch that may sway the asker to select their answer because they helped first.
Meaning Well
Look, the majority of these people have their heart in the right place, but not their posts. There could be many reasons that they don't have the capacity to post a fully considered and explained answer. I understand that writing error-free and well-formatted code with a thoughtful explanation on a mobile device is somewhat tedious. I've had limited time because of something going on in my life. I've been impatient and didn't "feel like" writing out a full explanation. These situations should not stop you from being a contributor!
If you really want to help...
GET TO THE REVIEW QUEUES!!!!
The review queues are integral in keeping StackExchange sites clean. The higher your rep points, the more reviewing you can do. Reviewing is so easy, you can do it while you eat your cereal, ride the train, etc. SE sites want you to review -- this is why they offer so many badges for it. This simple contribution will better serve the online community than answering a question with a comment.