Example 2 Find all real-valued functions $f$ defined on the set of rational numbers, satisfying $f(x+y)=f(x)+f(y)+2xy$.

 untranslated text remains unchanged.
Let $y=1, x=n \in N$. Then we have
$$
f(n+1)=f(n)+f(1)+2 n,
$$

which means $f(n+1)-f(n)=2 n+f(1)$.
$$
\begin{array}{c}
\therefore \sum_{i=1}^{n-1}[f(i+1)-f(i)] \\
=\sum_{i=1}^{n-1}[2 n+f(1)],
\end{array}
$$

which implies $f(n)=n^{2}+[f(1)-1] n=n^{2}+c n$
(let $f(1)-1=c$).
Also, $f\left(\frac{k+1}{n}\right)=f\left(\frac{k}{n}\right)+f\left(\frac{1}{n}\right)+\frac{2 k}{n^{2}}$,

which means $f\left(\frac{k+1}{n}\right)-f\left(\frac{k}{n}\right)=f\left(\frac{1}{n}\right)+\frac{2 k}{n^{2}}$,
$$
\begin{array}{c}
\therefore \sum_{k=1}^{n-1}\left[f\left(\frac{k+1}{n}\right)-f\left(\frac{k}{n}\right)\right] \\
=\sum_{k=1}^{n-1}\left[f\left(\frac{1}{n}\right)+\frac{2 k}{n^{2}}\right],
\end{array}
$$

which implies
$f\left(\frac{1}{n}\right)=\left(\frac{1}{n}\right)^{2}+c\left(\frac{1}{n}\right)$.
Similarly, $\sum_{k=1}^{m-1}\left[f\left(\frac{k+1}{n}\right)-f\left(\frac{k}{m}\right)\right]$
$$
=\sum_{k=1}^{m-1}\left[f\left(\frac{1}{n}\right)+\frac{2 k}{n^{2}}\right] .
$$

Thus, $f\left(\frac{m}{n}\right)-f\left(\frac{1}{n}\right)$
$$
\begin{array}{l}
=(m-1) f\left(\frac{1}{n}\right)+\frac{m(m-1)}{n^{2}} \text {. } \\
\therefore f\left(\frac{m}{n}\right)=\left(\frac{m}{n}\right)^{2}+c\left(\frac{m}{n}\right) \text {. } \\
\text { Let } x=y=0 \text {, then } f(0)=0 \text {. } \\
\therefore x=\frac{m}{n}, y=-\frac{m}{n} \text {, then } \\
f\left(\frac{m}{n}-\frac{m}{n}\right)=f\left(\frac{m}{n}\right)+f\left(-\frac{m}{n}\right) \\
-2\left(\frac{m}{n}\right)^{2} \\
\therefore f\left(-\frac{m}{n}\right)=2\left(\frac{m}{n}\right)^{2}-\left[\left(\frac{m}{n}\right)^{2}+c\left(\frac{m}{n}\right)\right] \\
=\left(-\frac{m}{n}\right)^{2}+c\left(-\frac{m}{n}\right) \text {. } \\
\end{array}
$$

Therefore, for $x \in Q$, we have $f(x)=x^{2}+c x, c$ is a constant.
Verify that $f(x)=x^{2}+c x$ satisfies the equation as required.
(3) Substitution Method
In the domain of the function, assign certain special values (expressions) to the independent variable, thereby finding the function's analytical form.