Equivalent conditions for a linear connection $\nabla$ to be compatible with Riemannian metric $g$

I am reading John M. Lee‘s Riemannian Manifolds: An Introduction to Curvature. In Lemma $5.2$, it is said that the following conditions are equivalent for a linear connection $\nabla$ on a Riemannian manifold:

(a) $\nabla$ is compatible with $g$.
i.e., for any vector fields $X,Y,Z$,
$$ \nabla_X g(Y,Z) = g(\nabla_X Y,Z) + g(Y,\nabla_X Z) $$
(b) $\nabla g\equiv 0.$

How do we go from (a) to (b) (and (b) to (a))?

Solutions Collecting From Web of "Equivalent conditions for a linear connection $\nabla$ to be compatible with Riemannian metric $g$"