Note that $g^{\mu\nu}T_{\mu\nu}$ is just another way of writing
$$
\sum_{\mu,\nu = 0}^3 g^{\mu\nu}T_{\mu\nu}
$$
Now, if we know that $T_{\mu\nu} = Q_{\mu\nu}$ for every $\mu,\nu = 0,\dots 3$, then we can simply substitute $Q_{\mu\nu}$ in for $T_{\mu\nu}$ in the sum. In other words
$$
\sum_{\mu,\nu = 0}^3 g^{\mu\nu}T_{\mu\nu} = \sum_{\mu,\nu = 0}^3 g^{\mu\nu}Q_{\mu\nu}
$$
but the sum on the right can be written using the summation convention as $g^{\mu\nu}Q_{\mu\nu}$. So, putting this all together, we have shown that
$$
g^{\mu\nu}T_{\mu\nu} = g^{\mu\nu}Q_{\mu\nu}
$$
Authors call it "tracing" because they are making an analogy with taking the trace of a matrix. Note, in particular, that if $g^{\mu\nu} = \delta^{\mu\nu}$ then we would have
$$
g^{\mu\nu}T_{\mu\nu} = \delta^{\mu\nu}T_{\mu\nu} = T_{\mu\mu} = \sum_{\mu=0}^3T_{\mu\mu} =\mathrm{tr}(T)
$$
where $T$ is the matrix with components $T_{\mu\nu}$.