Uniqueness of trace as linearization of the rank
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, it is written:
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?
Yes. More specifically, over any field $k$, regardless of its characteristic or algebraic closedness (or the lack of it), if $f : M_n(k) \to k$ is $k$-linear and $f(A)=\operatorname{rank}(A)$ (modulo $\operatorname{char}(k)$ if $k$ has finite characteristic) for every projection matrix $A$, then $f$ is necessarily the trace function.
Denote by $E_{ij}$ the matrix whose only nonzero entry is a $1$ at the $(i,j)$-th position. The assumption on $f$ implies that $f(E_{ii})=1$ for each $i$. Since $$ E_{12}=\left(\pmatrix{0&1\\ 0&1}\oplus I_{n-2}\right) - \operatorname{diag}(0,1,\ldots,1) $$ is a difference of two projections of equal ranks, we also have $f(E_{12})=0$ and similarly $f(E_{ij})=0$ whenever $i\ne j$. The linearity of $f$ thus implies that $f$ is the trace function.
Given any $A\in M_n(\mathbb C)$, we have $A=\text{Re}\,A+i\text{Im}\,A$, where $$ \text{Re}\,A=\frac{A+A^*}2,\ \ \ \text{Im}\,A-\frac{A-A^*}{2i} $$ are selfadjoint. So it is enough to test the assertion for selfadjoint matrices. In such case we have the spectral theorem available, which tells us that if $A=A^*$, then $$ A=\sum_{j=1}^n\lambda_j P_j, $$ where $P_j$ are (pairwise orthogonal) projections of rank-one. Then $$ f(A)=\sum_j\lambda_j f(P_j)=\sum_j\lambda_j=\text{Tr}\,(A). $$