- I have been writing 6 letters since morning.
- I have written 6 letters since morning.
Actually I thought that first sentence is correct but how second sentence is correct and first sentence is wrong
It is not that the one or the other is clearly and absolutely correct and the other is wrong. But we use the perfect to convey the idea that an action has been brought to completion. For that reason, in combination with "six letters" which implies a total count, the present perfect seems the natural choice. You have completed the task of writing six letters.
But let's say that you promised yourself that you would apply to six jobs today. You could easily say:
I have been writing those six cover letters all morning.
You have been writing those letters, and there is no indication in that progressive tense that you have completed the task. You may still be at it. There, in context, "those six letters" refers to a target or goal, not to something fully achieved.