If you think the question is duplicate why then you are sending an answer to it?
Often what happens is that someone answers and 10-20 minutes later comes across a duplicate of that same post, exactly what you said in one of the last paragraphs. That's the why, most frequently. It's basically answering first, but then thinking "Hmmm, this sounds quite generic. Has this been asked before?".
The other case is that you write an answer, you think it's solid, and then you come across something that explains same idea in a far better format. It's simply a mark of good "customer service" - you provide a solution, and if there's something better, you point the customer to that.
And finally there's what Oli's already mentioned - a canonical post might be overly generic and it's far more valuable to the OP to get an explanation in simpler format, but the question is still a duplicate. Here's a good example. OP came back after asking the same question, even though duplicates were provided, so I made it easy for them - provided a script, but the question is still a duplicate, so close vote has to be cast.
If you think it's not duplicate and the answer is different then why you are marking it as duplicate?
Just like in your first question, the assumption is that the person who answers knows in advance that question is a duplicate. More often than not one doesn't realize that until later on.
it just disallow the others to send an alternative solution to the question
Here's the thing: it's very easy to think of Ask Ubuntu ( or any Stack Overflow site ) as a race, as some sort of "answer olympics". It's not. I've been there, fell into the same trap, and used to yell at my screen: "Dammit ! I was writing an answer just now and you closed it! How dare you!"
That's the wrong way to look at things. People come to this site with specific questions/problems and for the most part they care about getting a solution, not about who closes what.
Closing a question as duplicate doesn't prevent other users from posting alternative solutions on the linked duplicates ( if such answer doesn't exist already, of course). In fact, posting on linked duplicates is much more beneficial, since those are often highly viewed and have more visitors, therefore better exposure for your answer to the world.
Nowadays if someone closes the question before I finish writing, I'm actually glad:"Oh, you found something better? Cool. Let's go check it out and learn what other ways there are to skin this cat." Providing value, quality content, and solving a person's problem are far more important that unicorn dollars (aka reputation points).
I can imagine a situation when you send an answer then you find that it's a duplicate however in that case I think casting to close is not cool again, if you believe it's duplicate and already has an answer then you should delete your answer, otherwise let others decide it should be closed or not.
Deleting an answer only robs the user of the information they just got. If it's a valid answer, deleting it just because question is a duplicate doesn't make sense. Same information can be explained in multiple ways, and a posted answer might be more clear to OP than a generic answer on a duplicate.
Letting others decide is ok, but it's simply delaying what will happen eventually anyway. Of course, one can always challenge the close vote and cast a reopen vote, but that's only if you think the question isn't a duplicate. If the question is actually a duplicate, then not closing it means keeping something that already has an answer (and maybe many alternative and more suitable answers) for no valid reason.