Let the left edge, width, and right edge of the first rectangle be $\ell_1$, $w_1$, and $r_1$. We have the relation $\ell_1 + w_1 = r_1$. Similarly, set $\ell_2$, $w_2$, and $r_2$ for the second rectangle, with the relation $\ell_2 + w_2 = r_2$.
You don't give any scale for "fully left" or "fully right". Your language makes it sound as if there is a third object somewhere that is being used to slide both rectangles. Let's suppose that third object, called $s$ for "setting", goes from $0$ (fully left) to $1$ (fully right).
When $s = 1$, we want $\ell_1 = \ell_2 = p_1$. When $s = 0$, we want $r_1 = r_2 = p_2$, or, what is the same, $\ell_1 + w_1 = \ell_2 + w_2 = p_2$. You don't exactly say as much, but your discussion of relative rates of motion of the two rectangles suggests you want to move the two rectangles linearly as a function of $s$. So let's look at the first rectangle and express the location of its left edge as a function of $s$, $\ell_1(s)$: $\ell_1(0) = p_2 - w_1$ and $\ell_1(1) = p_1$. Using the two point form of a line, we have \begin{align*}
\ell_1(s) &= \dfrac{p_1 - (p_2 - w_1)}{1 - 0}(s-1) + p_1 \\
&= (p_1 - p_2 + w_1)(s-1) + p_1 \text{.}
\end{align*}
Similarly, $\ell_2(0) = p_2 - w_2$ and $\ell_2(1) = p_1$, so
$$ \ell_2(s) = (p_1 - p_2 + w_2)(s-1) + p_1 \text{.} $$
It is possible that you intend to set one of the two rectangles directly (i.e., without using $s$) and would like to know where to set the other. This can be done by solving for $s$ as a function of $\ell_1$ and of $\ell_2$, then using that value of $s$ in the other rectangle. We have \begin{align*}
s(\ell_1) &= \dfrac{\ell_1 + w_1 - p_2}{p_1 + w_1 - p_2} \text{,} \\
s(\ell_2) &= \dfrac{\ell_2 + w_2 - p_2}{p_1 + w_2 - p_2} \text{,} \\
\ell_1(s(\ell_2)) = \ell_1(\ell_2) &= \dfrac{\ell_2(p_1 - p_2 + w_1) + p_1(w_2 - w_1)}{p_1 - p_2 + w_2} \text{, and} \\
\ell_2(s(\ell_1)) = \ell_2(\ell_1) &= \dfrac{\ell_1(p_1 - p_2 + w_2) + p_1(w_1 - w_2)}{p_1 -p_2 + w_1} \text{.}
\end{align*}
Having done this, we can directly answer your question: when you move the first rectangle by $1$ unit, the second rectangle moves by $\dfrac{p_1 - p_2 + w_2}{p_1 -p_2 + w_1}$ units (since this is exactly how much $\ell_2(\ell_1)$ changes when $\ell_1$ is incremented by $1$). Similarly, when we move the second rectangle by $1$ unit, the first rectangle moves by $\dfrac{p_1 -p_2 + w_1}{p_1 - p_2 + w_2}$ units.
(I note that the subexpression $p_1 - p_2$ appears frequently. If I were coding this, I would store that number rather than recompute it many times.)