The section below is from wikipedia:
The center of G is always a subgroup of G. In particular:
1. $Z(G)$ contains the identity element of $G$, $e$, because, for all $g \in G$, it commutes with $g$, $eg = g = ge$, by definition;
2. If $x$ and $y$ are in $Z(G)$, then so is $xy$, by associativity: $(xy)g = x(yg) = x(gy) = (xg)y = (gx)y = g(xy)$ for each $g \in G$; i.e., $Z(G)$ is closed;
3. If $x$ is in $Z(G)$, then so is $x^{−1}$ as, for all $g$ in $G$, $x^{−1}$ commutes with $g$: $(gx = xg) \implies (x^{−1}gxx^{−1} = x^{−1}xgx^{−1}) \implies (x^{−1}g = gx^{−1})$. Furthermore, the center of $G$ is always a normal subgroup of $G$, as it is closed under conjugation, as all elements commute.
I do not understand the last bit, why do all elements commute in $Z(G)$?
My attemt was to try to get $ab=ba$: $a,b \in Z(G) \implies \exists g,ga=ag, gb=bg\implies gagb=agbg$, but this doesnt't seem to lead anywhere useful.
The elements in the centre of a group, by definition, commute with all elements of the group $G$. Therefore they certainly commute with eachother.
Specifically, $Z(G) := \{ z \in G | zg = gz \; \forall g \in G\}$. If you have $a,b \in Z(G)$, then putting $a$ and $b$ into the definition above gives you what you want, right?