why does the velocity of the comet increases as it comes near the planets
It is accelerating due to the sun's gravity.
The question is that anything putted around the planet(that is, in region where the planet's field acts) suffers an interaction due to planet's field. This interaction is proportional to inverse of square of the distance between them. So, when this something is approaching to the planet, the interaction is increasing, consequently, its acceleration too, consequently, its velocity too.
Because of the conservation of energy, any object must gain velocity as it "drops" down a gravity well. It's not that much different than the reason a ball gains velocity if you drop and/or throw it downwards.
According to Keppler's law the area swept by any celestial body revolving around sun per unit time s constant. When a comet aprochs near to the sun its distance fromit decreases and to fulfill the condition its speed increases.
Separate names with a comma.