Hi there!
Gravity from the sun is even and makes a planet orbit the sun by exerting a force that pulls the planet towards it. Since the gravity of the sun is always the same (or very, very similar), the planet's orbit stays the same.
Hope this helps!