10. Given $p, q(q \neq 0)$ are real numbers, the equation $x^{2}-p x+q=0$ has two real roots $\alpha, \beta$, and the sequence $\left\{a_{n}\right\}$ satisfies $a_{1}=p, a_{2}=p^{2}-q, a_{n}=p a_{n-1}-q a_{n-2}(n=3,4, \cdots)$.
(1) Find the general term formula of the sequence $\left\{a_{n}\right\}$ (expressed in terms of $\alpha, \beta$);
(2) If $p=1, q=\frac{1}{4}$, find the sum of the first $n$ terms of $\left\{a_{n}\right\}$.
(1) Since $\alpha+\beta=p, \alpha \beta=q$, then $a_{n}=(\alpha+\beta) a_{n-1}-\alpha \beta a_{n-2}$
$\Rightarrow a_{n}-\alpha a_{n-1}=\beta\left(a_{n-1}-\alpha a_{n-2}\right) \Rightarrow\left\{a_{n+1}-\alpha a_{n}\right\}$ is a geometric sequence with a common ratio of $\beta$.
And $a_{2}-\alpha a_{1}=(\alpha+\beta)^{2}-\alpha \beta-\alpha(\alpha+\beta)=\beta^{2} \Rightarrow a_{n+1}-\alpha a_{n}=\beta^{n+1}$.
When $\alpha=\beta$, $\frac{a_{n+1}}{\alpha^{n+1}}-\frac{a_{n}}{\alpha^{n}}=1 \Rightarrow\left\{\frac{a_{n}}{\alpha^{n}}\right\}$ is an arithmetic sequence with a common difference of 1.
At this time, $a_{1}=\alpha+\beta=2 \alpha \Rightarrow \frac{a_{1}}{\alpha}=2 \Rightarrow \frac{a_{n}}{\alpha^{n}}=n+1 \Rightarrow a_{n}=(n+1) \alpha^{n}$.
When $\alpha \neq \beta$, let $a_{n+1}-\lambda \beta^{n+1}=\alpha\left(a_{n}-\lambda \beta^{n}\right) \Rightarrow a_{n+1}-\alpha a_{n}=\lambda\left(1-\frac{\alpha}{\beta}\right) \beta^{n+1}$
$\Rightarrow \lambda=\frac{\beta}{\beta-\alpha} \Rightarrow\left\{a_{n}-\frac{\beta^{n+1}}{\beta-\alpha}\right\}$ is a geometric sequence with a common ratio of $\alpha$.
At this time, $a_{1}=\alpha+\beta=\frac{\beta^{2}-\alpha^{2}}{\beta-\alpha} \Rightarrow a_{1}-\frac{\beta^{2}}{\beta-\alpha}=-\frac{\alpha^{2}}{\beta-\alpha}$
$\Rightarrow a_{n}-\frac{\beta^{n+1}}{\beta-\alpha}=-\frac{\alpha^{n+1}}{\beta-\alpha} \Rightarrow a_{n}=\frac{\beta^{n+1}-\alpha^{n+1}}{\beta-\alpha}=\frac{\alpha^{n+1}-\beta^{n+1}}{\alpha-\beta}$.
(2) From $\left\{\begin{array}{l}\alpha+\beta=1, \\ \alpha \beta=\frac{1}{4}\end{array} \Rightarrow \alpha=\beta=\frac{1}{2} \Rightarrow a_{n}=(n+1)\left(\frac{1}{2}\right)^{n}\right.$.
Thus, $S_{n}=2 \cdot \frac{1}{2}+3 \cdot\left(\frac{1}{2}\right)^{2}+4 \cdot\left(\frac{1}{2}\right)^{3}+\cdots+(n+1)\left(\frac{1}{2}\right)^{n}$
$$
\begin{array}{c}
\frac{1}{2} S_{n}=2 \cdot\left(\frac{1}{2}\right)^{2}+3 \cdot\left(\frac{1}{2}\right)^{3}+\cdots+n \cdot\left(\frac{1}{2}\right)^{n}+(n+1)\left(\frac{1}{2}\right)^{n+1} \\
\text { Thus } \frac{1}{2} S_{n}=2 \cdot \frac{1}{2}+\left(\frac{1}{2}\right)^{2}+\left(\frac{1}{2}\right)^{3}+\cdots+\left(\frac{1}{2}\right)^{n}-(n+1)\left(\frac{1}{2}\right)^{n+1} \\
=\frac{3}{2}-2 \cdot\left(\frac{1}{2}\right)^{n+1}-(n+1)\left(\frac{1}{2}\right)^{n+1}=\frac{3}{2}-(n+3)\left(\frac{1}{2}\right)^{n+1} \Rightarrow S_{n}=3-\frac{n+3}{2^{n}} .
\end{array}
$$