There seems consensus that the number of free real parameters of an $n \times n$ Hermitian matrix $M$ is $n^2$; see e.g. this post and also this short note.
On the other hand, such a matrix has a spectral decomposition $M = U D(\lambda) U^*$, where $U$ is an $n\times n$ unitary matrix, $U^*$ its adjoint, and $D(\lambda)$ is the diagonal matrix with entries $\lambda \in \mathbb{R}^n$. There are also posts, such as this one, suggesting that the number of free real parameters of an $n\times n$ unitary matrix is also $n^2$. Yet for "generic" Hermitian matrices $M$, the entries of $\lambda$ are distinct, and the spectral decomposition $M = U D(\lambda) U^*$ will be unique. Thus, specifying $M$ would seem to uniquely specify $n^2 + n$ real parameters, implying that the number of free real parameters of $M$ should be $n^2 + n$.
I suspect I'm missing something basic that would resolve this apparent discrepancy. Any suggestions would be appreciated!
(I'm also interested in the rank $r$ version of this question; specifying $r$ orthonormal vectors (by the same logic as the above post), and specifying a rank $r$ Hermitian matrix both appear to require $2nr - r^2$ real parameters, yet the Hermitian matrix also specifies $r$ eigenvalues.)