The formula :-
\begin{equation}\tag{A} \frac{1}{T_{syn}} = \frac{1}{T_{1}} - \frac{1}{T_{2}} \end{equation}
for the synodic period between two planets orbiting the Sun is derived in a similar way to the derivation of the Moon's synodic period :-
\begin{equation}\tag{B} \frac{1}{T_{syn}} = \frac{1}{T_{sid}} - \frac{1}{T_{e}} \end{equation}
where $T_{sid}$ is the sidereal perod of the Moon and $T_{e}$ is the sidereal period of the Earth.
Formula (B) is derived by making the following simplifying assumptions about the motions of the Sun, Earth and Moon :-
Earth has a circular orbit around the Sun of constant speed and a fixed period $T_{e}$
Moon has a circular orbit around the Earth of constant speed and a fixed period $T_{sid}$. (Thus the moon's path wrt the fixed Sun frame is an epicycle, ie a small circle whose center moves along the circumference of a larger circle, in this case the Earth's orbit).
The above two orbits are confined to a common plane (the Ecliptic Plane)
From the direction we are viewing (ie `North') both Earth and Moon orbit in the anti-clockwise direction
and (A) is derived with similar assumptions about the planetary orbits.
(See this answer for the derivation of formula (B) for the Moon - for the planets the derivation of (A) would be virtually the same).
In reality the orbits are not perfectly circular and they are not in the exact same plane. The circular orbit approximation means the speed of the planet is constant, but in the case of an elliptical orbit the speed varies.