If we have prepared an arbitrary anzats/trial two-qubit state:
$$\psi = a |00\rangle + b |01\rangle+ c |10\rangle+ d |11\rangle$$
And we want to calculate the expectation value of individual Pauli terms of this Hamiltonian that is the two qubit case of the used one in the VQE Cirq example:
$$ \langle H \rangle = \alpha_1 \langle Z_1 Z_2 \rangle + \alpha_2 \langle Z_1 \rangle + \alpha_3 \langle Z_2 \rangle $$
Note that:
\begin{align*}
\langle Z_1 Z_2 \rangle = |a|^2 - |b|^2 - |c|^2 + |d|^2 \\
\langle Z_2 \rangle = |a|^2 - |b|^2 + |c|^2 - |d|^2 \\
\langle Z_1 \rangle = |a|^2 + |b|^2 - |c|^2 - |d|^2
\end{align*}
So, just by performing measurements in the $Z$ basis will give you all the expectation values for the given $H$, because by these measurements we will obtain all the probabilities ($|a|^2$, $|b|^2$, $|c|^2$ and $|d|^2$). More about these calculations can be found in this answer. If there are other terms like $X_1 Y_2$ one should measure also in different basis (for more info here is my Qiskit tutorial on VQE, where at the end a procedure for finding the expectation value of $X_1 Y_2$ Pauli term is described).
What I used above is that all three terms have a common orthonormal basis. Maybe this is the crucial criterion, which implies the commutativeness. Here is a theorem from the M. Nielsen and I. Chuang textbook (page 77) about the common orthonormal basis of two commuting Hermitian matrices.
Theorem 2.2: (Simultaneous diagonalization theorem) Suppose $A$ and $B$ are Hermitian operators. Then $[A, B] = 0$ if and only if there exists an orthonormal basis such that both $A$ and $B$ are diagonal with respect to that basis. We say that A and B are simultaneously diagonalizable in this case.
P.S. I haven't read the Cirq's implementation, so maybe there will be a better answer.