Well, by definition
$$\delta_{ij}=\begin{cases}1, & \text{if} & i=j, \\0, & \text{if} & i\neq j,\end{cases}$$
and because of that, it should be clear that
$$a_{i}\delta_{ij}=\begin{cases}a_i, & \text{if} & i=j,\\0, & \text{if} & i\neq j\end{cases}.$$
But since $a_{i}\delta_{ij}=a_i$ just when $i=j$, we can write in this case $a_i\delta_{ij}=a_j$. Now sum the elements, along all the sum $\delta_{ij}$ will be zero, unless when the index $i$ hits $j$. Because of that we have
$$\sum_{i}a_i \delta_{ij} = a_j.$$
The other case can be handled similarly. Give it a try.
EDIT: What I meant is the following, write the sum explicitly
$$\sum_{i}a_i\delta_{ij} = a_1 \delta_{1j}+a_2\delta_{2j}+\cdots+a_{n-1}\delta_{(n-1)j}+a_n\delta_{nj}.$$
From all the terms in the sum, you can see the first index of the $\delta$ varying. Amongst all of them there'll be one such that $i=j$. For this particular one, $\delta_{jj}=1$ and for all the others it is zero. In that case, in the whole sum you have the contribution just from that term, which corresponds to $a_j$.