Well, if
$x, y \in Z(G), \tag 1$
then
$\forall g \in G, \; xg = gx, \; yg = gy$
$\Longrightarrow \forall g \in G, \; (xy)g = x(yg) = x(gy) = (xg)y = (gx)y = g(xy), \tag 2$
which shows that $Z(G)$ is closed under the group operation; clearly the identity element $e \in G$ satisfies
$eg = ge, \forall g \in G; \tag 3$
also,
$x \in Z(G) \Longrightarrow xg = gx, \forall g \in G \Longrightarrow gx^{-1} = x^{-1}g, \; \forall g \in G \Longrightarrow x^{-1} \in Z(G); \tag 4$
thus $Z(G)$ contains the group identity and also the inverse of each of its elements; since we have agreed that the associativity of the group operation is in fact manifestly inherited by $Z(G)$ from $G$, we conclude that $Z(G)$ is a subgroup of $G$. $OE\Delta$.