I always wrote "Thank you for your answer" for the answers in the comment section, but sometimes they were deleted. Is something like that unnecessary?
Not only is it unnecessary, it is considered an unwanted practice on the Stack Exchange.
The founders of Stack Exchange noticed that one annoying thing about many online forums is that, oftentimes, over time, roughly half the verbiage in a thread would be devoted to answering a question, while the other half would be filled with extraneous "idle talk," that is, with comments like, "Thank you," or, "You're welcome, glad to help." (See, for example, this thread – not the easiest conversation to follow!)
Also, threads completely unrelated to the forum's main topic might generate a lot of comments. As an example, see this thread about fake lunar landings, which is found on runner's forum, of all places. I think the SE founders got tired of combing through discussion forums that got cluttered like this.
This is why all SE sites begin their Help Center tours by saying:
We're a little bit different from other sites. Here's how:
Ask questions, get answers, no distractions
This site is all about getting answers. It's not a discussion forum. There's no chit-chat.
Moreover, another section entitled What should I do when someone answers my question concludes by saying:
Please do not add a comment on your question or on an answer to say "Thank you". Comments are meant for requesting clarification, leaving constructive criticism, or adding relevant but minor additional information – not for socializing. If you want to say "thank you," vote on or accept that person's answer, or simply pay it forward by providing a great answer to someone else's question. (emphasis in original)
At first glance, this might seem like it's promoting a culture of coldness, but that's not really the case. I've seen cases where a newer user will get three answers, and leave a comment under each one that says, "Thank you for your help." This repetition takes away from the "No distractions" model that the Stack Exchange tries to maintain.
Many people on the Stack Exchange are busy people, and they only have a small amount of time every day to devote to SE. Comments that say little more than "thank you", while well-intended, simply don't add much value. Most regulars would rather have an upvote than a thank-you comment – it's worth more and says as much.
I was going to leave this as a comment... however... ;)
Some stacks are chattier than others. Some clean up with prejudice after a brief period of chatty discourse; others leave it to posterity.
There's no hard & fast rule right across SE, but tidying up your own comments after a Question and Answer is firmly in place is a good way of 'self-policing' & honing the final discourse to the ideal...
One Question, Several Possible Answers, One of Which is Accepted
Courtesy is the lubrication of society, even on-line societies. It's part of the tragic culture of SE to reject that lubrication. "We are Borg. You will be assimilated." is not an expression of malice, simply a statement of fact.
That's what it feels like to spend a lot of time on SE. But then, it also pairs up well with the personalities. So, what are you going to do but continue to fight against it and be barraged with downvotes and threads of circular arguments?