I answered a question without thinking too much, and then it occurred to me that something similar must have been addressed before, and I found it. Should I remove my answer and mark the question as duplicate?
do mark the question as a duplicate. but don't remove your answer. although the answer may be essentially the same as the one for the question identified as a duplicate, someone coming to the site in the future may find this question first, and the fact that the answer is there may save that person from an additional step in finding an answer.
(on the other hand, if you find the duplicate before you've written an answer, just link it.)
some good guidelines appear in this question (which could conceivably be considered a duplicate of the present one).