Section 7.3 of Elements of Statistical Learning (2nd edition) gives the bias-variance decomposition for OLS prediction first for a single input $x_0$, and then averaged over a set of inputs $x_1, \dots, x_N$.
I understand where the variance term $||h(x_0)||^2 \sigma_{\varepsilon}^2$ in equation 7.11 comes from, since we have $\hat{f}_p(x_0) = \text{A}y$ for some matrix $A$, and $\text{Var}(Ay) = A\text{Var}(y)A^T$.
However, I don't understand where $p$ comes from in equation 7.12. When I try to compute the average of variance terms, it seems to me that we have $$ \frac{1}{N} \left[ ||X(X^TX)^{-1}x_1||^2 + \dots + ||X(X^TX)^{-1}x_N||^2 \right] = \frac{1}{N} ||X(X^TX)^{-1}X^T \mathbb{1}||^2, $$ where $\mathbb{1}$ is the $N \times 1$ column vector of 1's.