It follows from the assumptions that $g \circ f$ and $m$ are Tor independent (details omitted), hence the statement makes sense. In this proof we write $k^*$ in place of $Lk^*$ and $f_*$ instead of $Rf_*$. Let $a$, $b$, and $c$ be the right adjoints of Lemma \ref{lemma-twisted-inverse-image} for $f$, $g$, and $g \circ f$ and similarly for the primed versions. The arrow corresponding to the top square is the composition $$ \gamma_{top} : k^* \circ a \to k^* \circ a \circ l_* \circ l^* \xleftarrow{\xi_{top}} k^* \circ k_* \circ a' \circ l^* \to a' \circ l^* $$ where $\xi_{top} : k_* \circ a' \to a \circ l_*$ is an isomorphism (hence can be inverted) and is the arrow ``dual'' to the base change map $l^* \circ f_* \to f'_* \circ k^*$. The outer arrows come from the canonical maps $1 \to l_* \circ l^*$ and $k^* \circ k_* \to 1$. Similarly for the second square we have $$ \gamma_{bot} : l^* \circ b \to l^* \circ b \circ m_* \circ m^* \xleftarrow{\xi_{bot}} l^* \circ l_* \circ b' \circ m^* \to b' \circ m^* $$ For the outer rectangle we get $$ \gamma_{rect} : k^* \circ c \to k^* \circ c \circ m_* \circ m^* \xleftarrow{\xi_{rect}} k^* \circ k_* \circ c' \circ m^* \to c' \circ m^* $$ We have $(g \circ f)_* = g_* \circ f_*$ and hence $c = a \circ b$ and similarly $c' = a' \circ b'$. The statement of the lemma is that $\gamma_{rect}$ is equal to the composition $$ k^* \circ c = k^* \circ a \circ b \xrightarrow{\gamma_{top}} a' \circ l^* \circ b \xrightarrow{\gamma_{bot}} a' \circ b' \circ m^* = c' \circ m^* $$ To see this we contemplate the following diagram: $$ \xymatrix{ & & k^* \circ a \circ b \ar[d] \ar[lldd] \\ & & k^* \circ a \circ l_* \circ l^* \circ b \ar[ld] \\ k^* \circ a \circ b \circ m_* \circ m^* \ar[r] & k^* \circ a \circ l_* \circ l^* \circ b \circ m_* \circ m^* & k^* \circ k_* \circ a' \circ l^* \circ b \ar[u]_{\xi_{top}} \ar[d] \ar[ld] \\ & k^*\circ k_* \circ a' \circ l^* \circ b \circ m_* \circ m^* \ar[u]_{\xi_{top}} \ar[rd] & a' \circ l^* \circ b \ar[d] \\ k^* \circ k_* \circ a' \circ b' \circ m^* \ar[uu]_{\xi_{rect}} \ar[ddrr] & k^*\circ k_* \circ a' \circ l^* \circ l_* \circ b' \circ m^* \ar[u]_{\xi_{bot}} \ar[l] \ar[dr] & a' \circ l^* \circ b \circ m_* \circ m^* \\ & & a' \circ l^* \circ l_* \circ b' \circ m^* \ar[u]_{\xi_{bot}} \ar[d] \\ & & a' \circ b' \circ m^* } $$ Going down the right hand side we have the composition and going down the left hand side we have $\gamma_{rect}$. All the quadrilaterals on the right hand side of this diagram commute by Categories, Lemma \ref{categories-lemma-properties-2-cat-cats} or more simply the discussion preceding Categories, Definition \ref{categories-definition-horizontal-composition}. Hence we see that it suffices to show the diagram $$ \xymatrix{ a \circ l_* \circ l^* \circ b \circ m_* & a \circ b \circ m_* \ar[l] \\ k_* \circ a' \circ l^* \circ b \circ m_* \ar[u]_{\xi_{top}} & \\ k_* \circ a' \circ l^* \circ l_* \circ b' \ar[u]_{\xi_{bot}} \ar[r] & k_* \circ a' \circ b' \ar[uu]_{\xi_{rect}} } $$ becomes commutative if we invert the arrows $\xi_{top}$, $\xi_{bot}$, and $\xi_{rect}$ (note that this is different from asking the diagram to be commutative). However, the diagram $$ \xymatrix{ & a \circ l_* \circ l^* \circ b \circ m_* \\ a \circ l_* \circ l^* \circ l_* \circ b' \ar[ru]^{\xi_{bot}} & & k_* \circ a' \circ l^* \circ b \circ m_* \ar[ul]_{\xi_{top}} \\ & k_* \circ a' \circ l^* \circ l_* \circ b' \ar[ul]^{\xi_{top}} \ar[ur]_{\xi_{bot}} } $$ commutes by Categories, Lemma \ref{categories-lemma-properties-2-cat-cats}. Since the diagrams $$ \vcenter{ \xymatrix{ a \circ l_* \circ l^* \circ b \circ m_* & a \circ b \circ m \ar[l] \\ a \circ l_* \circ l^* \circ l_* \circ b' \ar[u] & a \circ l_* \circ b' \ar[l] \ar[u] } } \quad\text{and}\quad \vcenter{ \xymatrix{ a \circ l_* \circ l^* \circ l_* \circ b' \ar[r] & a \circ l_* \circ b' \\ k_* \circ a' \circ l^* \circ l_* \circ b' \ar[u] \ar[r] & k_* \circ a' \circ b' \ar[u] } } $$ commute (see references cited) and since the composition of $l_* \to l_* \circ l^* \circ l_* \to l_*$ is the identity, we find that it suffices to prove that $$ k \circ a' \circ b' \xrightarrow{\xi_{bot}} a \circ l_* \circ b \xrightarrow{\xi_{top}} a \circ b \circ m_* $$ is equal to $\xi_{rect}$ (via the identifications $a \circ b = c$ and $a' \circ b' = c'$). This is the statement dual to Cohomology on Sites, Remark \ref{sites-cohomology-remark-compose-base-change} and the proof is complete.