For a weighting matrix $\hat W$, regressor matrix $Z$ (following the somewhat unusual notation used in the book by Hayashi you are referring to) and instrument matrix $X$, the GMM estimator to estimate $\delta$ in a linear model $y=Z\delta+\epsilon$ can be written as
$$
\widehat{\delta}(\widehat{W})=(Z'X\widehat{W}X'Z)^{-1}Z'X\widehat{W}X'y.
$$
If you assume your regressors to be "valid" (aka exogenous, uncorrelated with the error term), the $Z$ may be a subset of the set of instruments $X$, or they may even coincide with $X$, $Z=X$.
Consider the latter case first. GMM becomes (notice the matrices in the inverse then are square so that the inverse can be written as the product of the inverses, in reverse order)
\begin{align*}
\widehat{\delta}(\widehat{W})&=(Z'Z\widehat{W}Z'Z)^{-1}Z'Z\widehat{W}Z'y\\
&=(Z'Z)^{-1}\widehat{W}^{-1}(Z'Z)^{-1}Z'Z\widehat{W}Z'y\\
&=(Z'Z)^{-1}Z'y,
\end{align*}
which is the OLS estimator.
For the first case, we get equality for the particular choice of weighting matrix (optimal under conditional homoskedasticity) $\hat W=(X'X)^{-1}$:
GMM then becomes
\begin{align*}
\widehat{\delta}((X'X)^{-1})&=(Z'X(X'X)^{-1}X'Z)^{-1}Z'X(X'X)^{-1}X'y\\
&:=(Z'P_XZ)^{-1}Z'P_Xy,
\end{align*}
known as two-stage least squares. Now, if $Z\subset X$, projecting $Z$ on $X$ via $P_XZ$ will simply give $Z$ again (you explain something by itself and other instruments, and the best way to explain a variable is by itself - you will get perfect fit). Hence, GMM will again reduce to OLS.