[proofplan]
We compute directly from the definition $H=X(X^\top X)^{-1}X^\top$. Full column rank ensures that $X^\top X$ is invertible, so the formula is well-defined. Symmetry and idempotence give the projection algebra needed to control the quadratic forms $e_i^\top H e_i$ on standard basis vectors $e_i \in \mathbb{R}^n$. The trace is then computed by cyclically rearranging the finite-dimensional matrix trace.
[/proofplan]
[step:Verify that the hat matrix is well-defined]
Since $X$ has full column rank $p$, its columns are linearly independent. Hence, for every nonzero vector $v \in \mathbb{R}^p$,
\begin{align*}
v^\top X^\top X v = |Xv|^2 > 0.
\end{align*}
Therefore $X^\top X \in \mathbb{R}^{p \times p}$ is symmetric positive definite, so it is invertible. Thus
\begin{align*}
H = X(X^\top X)^{-1}X^\top
\end{align*}
is a well-defined element of $\mathbb{R}^{n \times n}$.
[/step]
[step:Compute symmetry and idempotence from the defining formula]
Let
\begin{align*}
A := (X^\top X)^{-1} \in \mathbb{R}^{p \times p}.
\end{align*}
Let $I_p \in \mathbb{R}^{p \times p}$ denote the identity matrix. Since $X^\top X$ is symmetric, its inverse $A$ is also symmetric. Therefore
\begin{align*}
H^\top
&= \bigl(XAX^\top\bigr)^\top \\
&= XA^\top X^\top \\
&= XAX^\top \\
&= H.
\end{align*}
For idempotence, use associativity of matrix multiplication and the identity $(X^\top X)A=I_p$:
\begin{align*}
H^2
&= \bigl(XAX^\top\bigr)\bigl(XAX^\top\bigr) \\
&= XA(X^\top X)AX^\top \\
&= XAI_pX^\top \\
&= XAX^\top \\
&= H.
\end{align*}
Thus $H$ is symmetric and idempotent.
[/step]
[step:Bound each diagonal entry by projecting a standard basis vector]
For each $i \in \{1,\dots,n\}$, let $e_i \in \mathbb{R}^n$ denote the $i$-th standard basis vector. The $(i,i)$-entry of $H$ is
\begin{align*}
h_{ii} = e_i^\top H e_i.
\end{align*}
Using symmetry and idempotence,
\begin{align*}
h_{ii}
&= e_i^\top H e_i \\
&= e_i^\top H^\top H e_i \\
&= (He_i)^\top(He_i) \\
&= |He_i|^2.
\end{align*}
Hence $h_{ii} \geq 0$.
To prove the upper bound, decompose
\begin{align*}
e_i = He_i + (I_n-H)e_i,
\end{align*}
where $I_n \in \mathbb{R}^{n \times n}$ is the identity matrix. The two summands are orthogonal because
\begin{align*}
(He_i)^\top((I_n-H)e_i)
&= e_i^\top H^\top(I_n-H)e_i \\
&= e_i^\top H(I_n-H)e_i \\
&= e_i^\top(H-H^2)e_i \\
&= 0.
\end{align*}
By the Pythagorean identity in $\mathbb{R}^n$,
\begin{align*}
|e_i|^2 = |He_i|^2 + |(I_n-H)e_i|^2.
\end{align*}
Since $|e_i|^2=1$ and $|(I_n-H)e_i|^2 \geq 0$, we get
\begin{align*}
h_{ii}=|He_i|^2 \leq 1.
\end{align*}
Therefore $0 \leq h_{ii} \leq 1$ for every $i \in \{1,\dots,n\}$.
[/step]
[step:Compute the trace by moving conformable finite matrices cyclically]
For finite matrices $B \in \mathbb{R}^{n \times p}$ and $C \in \mathbb{R}^{p \times n}$, the trace identity
\begin{align*}
\operatorname{tr}(BC)=\operatorname{tr}(CB)
\end{align*}
follows by expanding entries:
\begin{align*}
\operatorname{tr}(BC)
&= \sum_{i=1}^{n} (BC)_{ii} \\
&= \sum_{i=1}^{n}\sum_{j=1}^{p} B_{ij}C_{ji} \\
&= \sum_{j=1}^{p}\sum_{i=1}^{n} C_{ji}B_{ij} \\
&= \sum_{j=1}^{p} (CB)_{jj} \\
&= \operatorname{tr}(CB).
\end{align*}
Apply this identity with $B=X$ and $C=(X^\top X)^{-1}X^\top$. Then
\begin{align*}
\operatorname{tr}(H)
&= \operatorname{tr}\bigl(X(X^\top X)^{-1}X^\top\bigr) \\
&= \operatorname{tr}\bigl((X^\top X)^{-1}X^\top X\bigr) \\
&= \operatorname{tr}(I_p) \\
&= p.
\end{align*}
This proves all asserted properties of the hat matrix.
[/step]