The function T(A) = tr(A) is not a function from Mnn to Mnn. It is the function from Mnn to R (to real numbers, or to the base coefficients field, in general). Learn basics of your science.