Example 8 Let $Q$ be the set of all rational numbers, find all functions $f$ from $\mathrm{Q}$ to $\mathrm{Q}$ that satisfy the following conditions:
(1) $f(1)=2$;
(2) For any $x, y \in \mathrm{Q}$, $f(x y)=f(x) f(y)-f(x+y)+1$.


Solution: In (2), let $y=1$ to get
$$
f(x)=f(x) f(1)-f(x+1)+1.
$$

Given $f(1)=2$, we have $f(x+1)=f(x)+1$. Therefore,
when $n$ is a positive integer, $f(x+n)=f(x+n-1)+1=\cdots=f(x)+n$.
When $n=-m$ is a negative integer, $f(x+n)=f(x-m)=f(x-m+1)-1=f(x-m+2)-2=\cdots=f(x)-m=f(x)+n$.
Thus, when $n$ is an integer, $f(x+n)=f(x)+n$.
Hence, $f(n+1)=f(1)+n=n+2$.
This proves that when $x$ is an integer, $f(x)=x+1$.
For any rational number $\frac{n}{m}$ (where $m, n$ are integers and $m \neq 0$), in (2), let $x=m, y=\frac{n}{m}$, to get
$$
f(n)=f\left(m \cdot \frac{n}{m}\right)=f(m) f\left(\frac{n}{m}\right)-f\left(m+\frac{n}{m}\right)+1.
$$

Thus, the above equation can be simplified to
$$
n+1=(m+1) f\left(\frac{n}{m}\right)-\left[f\left(\frac{n}{m}\right)+m\right]+1, \text{ which gives } f\left(\frac{n}{m}\right)=\frac{n}{m}+1.
$$

Therefore, when $x \in \mathrm{Q}$, $f(x)=x+1$.
Upon verification, $f(x)=x+1$ satisfies conditions (1) and (2), hence $f(x)=x+1$.