Do the orbits of planets change sometimes?
Yes, the orbits change massively over time. For example, Earth's eccentricity (how close to a circle the orbit is), its axial tilt (what causes seasons), and precession (which direction the Earth's spin axis points) change on these huge cycles, tens of thousands to hundreds of thousands of years long. They are caused by the pull of the other planets, mainly Jupiter and Saturn (since they are so huge), as well as the physics of inertial reference frames. These are known as the Milankovitch cycles. Here is a neat video explaining what each of the cycles are in detail. That video is about Earth, but the same concepts apply to all the other planets too, just on different amounts and timescales.
An asteroid hitting a planet would technically change its orbit, however how much is questionable. An asteroid a couple km across would barely nudge the Earth since the Earth is bigger by many orders of magnitude. It would also destroy everything on the planet, but thats another story. Way back in the solar system's formation, when Thea hit Earth (theoretically) it was much closer in size than the Earth, so no doubt that it caused a much more significant shift in orbit.