Example 4 Let $f(x)$ be a function defined on $\mathbf{R}$, for any $x \in \mathbf{R}$, we have $f(x+3) \leqslant f(x)+3$ and $f(x+$ $2) \geqslant f(x)+2$. Let $g(x)=f(x)-x$, if $f(4)$ $=2008$, find $f(2008)$.
Given: $\because g(x)=f(x)-x$, we can obtain $g(x+2)=$ $f(x+2)-x-2, g(x+3)=f(x+3)-x-3$,

Substituting $f(x+3) \leqslant f(x)+3$ and $f(x+2) \geqslant$ $f(x)+2$, we get
$$
\begin{array}{l}
g(x+2) \geqslant f(x)+2-x-2=f(x)-x, \text { (1) } \\
g(x+3) \leqslant f(x)+3-x-3=f(x)-x, \text { (2) }
\end{array}
$$

From (1), we get $g(x+4) \geqslant f(x+2)-x-2 \geqslant f$
$$
\begin{array}{l}
(x)+2-x-2=f(x)-x, \\
\quad \therefore g(x+6) \geqslant f(x+2)-x-2 \geqslant f(x)-x
\end{array}
$$
(3); From (2), we get $g(x+6) \leqslant f(x+3)-x-3 \leqslant$ $f(x)-x$ (4);

From (3) and (4), we know $g(x+6)=f(x)-x=g(x)$. $\therefore g(x)$ is a periodic function (6 is one of its periods).
$$
\begin{aligned}
\because g(2008)=g(334 \times 6+4)=g(4)= \\
f(4)-4=2008-4=2004, \\
\therefore f(2008)=g(2008)+2008=2004+ \\
2008=4012 .
\end{aligned}
$$