The rectangle is made of $800 \times 200$ "boxes". The diagonal thus has gradient $\pm \frac{200}{800} = \pm \frac{1}{4}$, where a "box" has unit dimensions. Note the diagonal starts at the top left corner of the top-left-most box. This is important. So, after 4 units of width travelled, the diagonal will intersect the top left corner of another box:
And this section of the diagonal intersects four boxes. Since the rectangle is 800 boxes wide, this section of the diagonal will repeat $\frac{800}{4} = 200$ times, and so the diagonal intersects $4 \times 200 = 800$ boxes.
A more interesting problem is to consider a rectangle of dimensions $p \times q$ where $p$ and $q$ are distinct primes. Then the diagonal never intersects the top-left corner of a box within the rectangle, and a different approach is called for: