Some confusions about instrumental variable (econometrics)
Endogenous variables are correlated with the error terms and z is
  correlated with endogenous variable.
  
  Doesn't this imply that z is correlated with error terms?


No it doesn't. For mean-centered variables for simplicity, we have for linear models,

ENDOGENEITY: $E(xu) \neq 0$  

RELEVANCE : $E(xz) \neq 0$

The above conditions do not necessarily imply non-Validity ($E(zu) \neq 0$).

A very simple example to show that we may have a valid instrument.
Assume $x, u$ are centered on their mean, $E(x) = E(u) = 0$, and that $x$ has a symmetric distribution, $E(x^3) = 0$. Assume that  $E(u \mid x) = ax$.
Then  

ENDOGENEITY

$$E(xu) = E\big[E(xu\mid x)\big] =  E\big[xE(u\mid x)\big] = aE(x^2) \neq 0.$$

Consider the candidate instrument $z = x^2 + v$, with $v$ independent from $u$, but $E(xv) \neq 0$. We have

RELEVANCE
$$E(xz) = E(x^3) + E(xv) = 0 + E(xv) \neq 0$$.

VALIDITY

$$E(zu) = E(x^2u) + E(vu) = E\big[E(x^2u\mid x)\big] + E(v)E(u)$$

$$= E\big[x^2E(u\mid x)\big] + 0 = E\big[x^2a x\big] = aE(x^3) = 0.$$