I'm going through a book on tensors and I found the following example:
But this does not seem right to me because the Einstein's summation convention states: sum whenever there are two repeated indices one as superscript and the other as subscript.
The summation range must be from $1$ to $n$.
In the expression $$a_{ij} x^i x^j$$ we have a pair of repeated indices $i$ and $j$, each ocurring once as superscript and another as subscript. In my understanding of the rulle it should be
$$\begin{align*} a_{ij} x^i x^j&=a_{1j} x^1 x^j+\ldots +a_{nj} x^n x^j\\ &=(a_{11} (x^1)^2+a_{12} x^1 x^2+\ldots +a_{1n} x^1 x^n)+\ldots +(a_{n1} x^n x^1 +\ldots +a_{nn} (x^n)^2). \end{align*} $$
Am I missing something?

You're right: (i) should contain $n^2$ terms, whereas the solution given only brings the $n$ "diagonal" ones to mind. The only way this can be OK is if the matrix $a$ is diagonal.