Sort:  

Because it is rotating. The force due to the planet is not the only force acting on the planet. The stronger force is the gravitational force of the sun. One easy way to think about it is that it constantly "falls" towards the planet, but the planet moves away, so it tries to fall again, but the planet is still moving away.