Calculating a determinant.

Expand with respect to the first line: the term obtained with $a$ is $aD_{n-1}$. For the second one, we get $(-1)^{n+1}$ times a determinant that can be expanded with respect to the first column. This lead to the recurrence relation $$ D_n=aD_{n-1}-\left(n-1\right)^2a^{n-2}. $$ Letting $b_n:=a^{-n}D_n$ for $a\neq 0$ allows to derive and easier recurrence relation whose resolution shows that the formula mentioned in the opening post, namely, $$ D_n=a^n - a^{n-2}\sum_{i=1}^{n-1}i^2, $$ is correct.


Develop with respect to the first column. Then $$ \begin{aligned} D_n &= aD_{n-1} -(n-1)\cdot (n-1)\cdot a^{n-2} \\ &=aD_{n-1}-(n-1)^2a^{n-2}\ . \end{aligned} $$ This recursion, together with $D_1=a$ gives for $n\ge 2$ the solution $$ D_n= (a^2-(1^2+2^2+\dots+(n-1)^2)a^{n-2}\ . $$ (The sum in the first factor has a closed formula.)


You can just go for calculating the characteristic polynomial $\chi_{-A}$ of minus the matrix $A$ (the one at $a=0$), then your determinant will be $\chi_{-A}[a]$. As you already found that the rank of $A$ is$~2$ (if $n\geq2$; otherwise it is $0$) the coefficients of $\chi_{-A}$ in all degrees less than $n-2$ are zero (as its coefficient of degree $n-r$ is the sum of all principal $r$-minors of$~A$. Since $A$ has zero trace, one has $$\chi_{-A}=X^n+0x^{n-1}+c_nX^{n-1}$$ where $c_n$ is the sum of all principal $2$-minors of$~A$, which is easily seen to be $$ c_n=-\sum_{k=0}^{n-1}k^2=-\frac{2n^3-3n^2+n}6.$$ Therefore $\det(D_n)=a^n+c_na^{n-2}=a^{n-2}(a^2+c_n)$, as you guessed (with $c_n\leq0$, so the roots of $\chi_{-A}$ are real: $\pm\sqrt{-c_n}$ and $0$ with multiplicity $n-2$).