First of all: you never raised any flags nor are you linking to anything, so you didn’t give us much context.
However, I’m pretty sure I have found the specific flag that prompted this question, which read:
A duplicate answer. Spam.
If this was indeed the reason that promoted this question, then we can start with the reasons why this flag was declined. You didn’t tell us what content it was duplicating but there is just one other answer to that question.
While the code looks a lot like the other answer, there is a difference between the two answers, so a direct comparison shows the answer is not just a duplicate. If you think the difference should be ignored, say, because the language of framework treats either variant as the same, please make that explicit in the flag as moderators are human and don’t know the ins and outs of every possible programming language and tool.
More importantly however is that the two answers were posted within minutes of each other. The second answer was almost certainly posted in good faith, and we generally don’t delete answers when they’re the same but posted in close proximity to one another.
So, for answers to the same question that offer the same solution, we only honour such flags if the newer answer was posted significantly later and doesn’t offer any improvement over the older answer. Significantly here means hours later, but most such answers were posted up to years later.
I’m ignoring the “Spam” part there. Stack Overflow uses a very narrow and specific definition of “spam”, and the answer didn’t promote anything.
Your question is also alluding to having seen deleted answers with moderator comments on them asking the user not to duplicate answers. As the account that raised the above flag does have 10K+ reputation and so can see deleted posts I’m assuming they perhaps saw comments like the one I use:
Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, tailor your answers to the question.
I use this comment for a completely different situation, namely where a user copied their own answer from one question to another. Please don’t confuse these two scenarios. Moderators receive automated flags for the majority of such posts, but if you find identical answers by the same user, posted to multiple questions, feel free to flag those with a reference to the first such answer.
TLDR:
Please do flag redundant late answers to questions that are already answered, where the late answer was posted significantly later than existing answers and where the late answer doesn’t add anything new. Do include a clear reference to the specific answer you feel makes the late answer redundant.
If you see multiple copies of the same answer by the same user, posted to multiple questions, please let us know about those too, and reference the oldest answer in your flag. Make it clear the same user posted these.