Example 7 Find all functions $f: \mathbf{Q} \rightarrow \mathbf{Q}(\mathbf{Q}$ is the set of rational numbers), such that (1) $f(1)=2$; (2) For any $x, y \in \mathbf{Q}$,
$$
f(x y)=f(x) f(y)-f(x+y)+1
$$
Let $y=1$ in (2), and using (1), we get $f(x+1)=f(x)+1$.
Using condition (1) and the above equation, it is easy to prove by mathematical induction that for any integer $n$, $f(n)=n+1$. Moreover, for any rational number $x$ and integer $n$, we have $f(x+n)=f(x)+n$.
Next, we prove that for any rational number $\frac{n}{m}$, $f\left(\frac{n}{m}\right)=\frac{n}{m}+1$.
Let $x=m, y=\frac{n}{m}$, substitute into condition (2), we get $f(n)=f(m) \cdot f\left(\frac{n}{m}\right)-f\left(m+\frac{n}{m}\right)+1$.
That is, $n+1=(m+1) f\left(\frac{n}{m}\right)-\left(f\left(\frac{n}{m}\right)+m\right)+1$. Therefore, $f\left(\frac{n}{m}\right)=\frac{n}{m}+1$.
Thus, for any rational number $x$, we have $f(x)=x+1$, which is indeed a solution to the original functional equation.