It is not difficult to show that if $A \in M_n(k)$ for some field $k$, and $A^2=A$ then
$$\operatorname{tr}(A) = \dim(\operatorname{Im}(A))$$
In this comment, Terry Tao wrote:
This property, together with linearity, determines the trace uniquely, and so one can view the trace as the linearised version of the dimension-counting operator.
What does it mean precisely? If $f : M_n(k) \to k$ is $k$-linear (say with $k = \Bbb C$), and $f(A) = \dim(\operatorname{Im}(A))$ for any $A^2= A \in M_n(k)$, then we have that $f$ is the trace function?