Green function $G(x,y)$ is a function satisfying $\Delta G(x,y)=\delta (x-y)$ where $\delta$ is Dirac's delta.
Brownian motion on $\mathbb{R}^2$ is recurrent, so we have $G(x,y)=\int _0^\infty p(t,x,y)dt =\infty $ for the heat kernel $p(t,x,y)$. But it is known that $G(x,y)=-\frac{1}{2\pi }\log|x-y|$ is green function. I think this is contradiction. Or these green functions are not same ones?
Yes, there is, in a sense, two different Green's functions at play here.
So what is the Green's Operator $\mathscr{G}$? Well, a simple way to define it is that it is a linear operator such that, for suitable test functions $f$, say smooth and compactly supported, we have $\frac{1}{2}\Delta \mathscr{G}f=-f$ (the sign difference and the factor of $\frac{1}{2}$ being a convention). Note that this uniquely determines $\mathscr{G}$ up to addition by some (potentially $f$-dependent) harmonic function. By Liouville's theorem, we get uniqueness if we impose that $\mathscr{G}f$ is bounded.
Now, in classical harmonic analysis, we know that there exists a green's function $G(x,y)$ on $\mathbb{R}^d$ such that $$ \mathscr{G}f(x)=\int_{\mathbb{R}^d} G(x,y)f(y)\textrm{d}y, $$ which is characterised by the property that, in the distributional sense, $\Delta_x G(x,y)=\delta_{x-y}$.
However, there is another way to construct the Green's Operator via Brownian Motion. Indeed, if $p_t(x,y)$ is the transition density, you can check that $$ \mathscr{G}f(x)=\int_0^{\infty} (p_t*f)(x)\textrm{d}t=\int_0^{\infty} (2\pi t)^{-d/2} \int_{\mathbb{R}^d} e^{-\frac{\|x-y\|^2}{2t}} f(y)\textrm{d}y\textrm{d}t, $$
Now, if $d\geq 3$, we see that $$\int_1^{\infty} p_t(x,y)\textrm{d}t\leq \int_1^{\infty} (2\pi t)^{-d/2}\textrm{d}t<\infty,$$ so that we can exchange the order of integration and thus get that
$$ \mathscr{G}f(x)=\int_{\mathbb{R}^d} f(y) \int_0^{\infty} p_t(x,y)\textrm{d}t \textrm{d}y, $$ so that $G(x,y)=\int_0^{\infty} p_t(x,y)\textrm{d}t$, since the smooth functions with compact support are dense in $L^1$ and both of the functions are continuous except where they blow up.
However, this does not work in 2 dimensions since, as you point out, $\int_0^{\infty} p_t(x,y)\textrm{d}t=\infty$ and hence, we cannot change the order of integration the way we would like to. However, the two objects (the Green's function and the transition density) are still linked by the above identities.