Say we have a diagonal metric with components $g_{\mu \nu}$. When contracting with the inverse metric, we have the identity $$ g_{\mu \nu}g^{\nu \lambda} = \delta_{\mu}^{\lambda}.$$ When both pairs of components are equal, in the Einstein summation convention contraction should leave us with the trace of the Kronecker delta, $$ g_{\mu \nu}g^{\nu \mu} = \delta_{\mu}^{\mu} = n$$ on an $n$-dimensional manifold.
Now let us say we have contracted a rank-2 tensor to form a scalar by $$ g^{\nu \lambda}T_{\lambda\nu} = t.$$ If we multiply by the metric following the first equation above, we find \begin{align} g_{\mu\nu}g^{\nu \lambda}T_{\lambda\nu} &= g_{\mu\nu}t, \\ \Rightarrow \delta_{\mu}^{\lambda}T_{\lambda\nu}&= T_{\mu\nu} = g_{\mu\nu}t. \end{align} If however we multiply by the metric using the same indices, as in the second case above, we find \begin{align} g_{\mu\nu}g^{\mu\nu}T_{\mu\nu} &= g_{\mu\nu}t, \\ \Rightarrow \delta_{\mu}^{\mu}T_{\mu\nu}&= g_{\mu\nu}t. \end{align} It seems clear that one can contract the Kronecker delta upper $\mu$ index with the lower $\mu$ index in $T_{\mu\nu}$ to obtain the same result as the first time. What is unclear to me is exactly why the interpretation $\delta_{\mu}^{\mu}=n $ in this case is incorrect. I can't seem to justify with proper rigour why that contraction makes no sense here, even though I can see that it's wrong and am otherwise happy with the correct interpretation.
My intuition is that the LHS has to be treated like a rank 4 tensor, and the trace of this tensor over the delta indices does not mean we introduce a scalar factor to the resulting contracted tensor. But this isn't a very thorough description.
Does anyone have any pointers? I'm positive I'm overlooking something very simple but quite important here.