Let's say I took a GRE test and got a perfect 340 score for Verbal and Quantitative sections but very low score on Analytical Writing, and then retake GRE again to improve the Writing score and got 6 for this 2nd attempt. Can I take the 340 of Verbal-Quant from the 1st test and take the 6 of Writing from the 2nd test to apply for Graduate program?
I can't find an explicit statement from ETS, but their ScoreSelect option allows you to send scores from any or all exams from the last 5 years and you select by test date. There's no option to pick individual sections from different dates.
With the ScoreSelect® option, you can send scores from Most Recent, All or Any specific test administration of the GRE General Test and/or Subject Tests.
A quick answer to your question is No, you cannot mix both scorecards. You can send both scores but it depends upon the school which scorecard they would consider as the school you applied to will have your both scores on file.
Based on my own experience, quant and verbal scores matter more than analytical scores. Generally, if you are going into fields that require maths/stats, your quant score has a higher weight compared to your analytical score. So, if you have a good score on those two and a satisfactory score on the analytical part, I would recommend using that one compared to the one with a low score on quant and verbal but good in the analytical part. But if you have a not-so-good score in quantitative and verbal and an excellent score in analytical, that may not help much. You did not mention how you did in your second GRE test in quant and verbal. If you still have good scores in quant and verbal on your second attempt and 6 in analytical, you may benefit by sending a second scorecard.
Also please note that GRE is essential but not the only factor needed for admission. If another person has average GRE scores but a better grip on research and a better research match with faculty, that person might get accepted. In summary, multiple factor plays in admission decisions and you have to decide how to balance them properly for successful admission.