12. Let the function $f(x): \mathbf{R} \rightarrow \mathbf{R}$, and it satisfies for any $x, y \in \mathbf{R}$,
$$
\begin{array}{l}
f(x) f(y) \\
=f(2 x y+3)+3 f(x+y)-3 f(x)+6 x .
\end{array}
$$

Then $f(x)=$
12. $f(x)=2 x+3$.

Swapping $x$, we get
$$
-3 f(x)+6 x=-3 f(y)+6 y \text {. }
$$

Thus, $f(x)-2 x$ is a constant.
Let $f(x)=2 x+a$.
$$
\begin{aligned}
\text { By } & (2 x+a)(2 y+a) \\
= & 2(2 x y+3)+a+3(2 x+2 y+a)- \\
& 3(2 x+a)+6 x,
\end{aligned}
$$

we get
$$
\begin{array}{l}
2(x+y)(3-a)=a^{2}-a-6 \\
=(a-3)(a+2),
\end{array}
$$

which simplifies to $(a-3)\left(x+y+\frac{a}{2}+1\right)=0$.
The above equation holds for any real numbers $x, y$. Hence, $a=3$. Therefore, $f(x)=2 x+3$.