This formula derivates from how you write the representation of Operators, so, you begin to the operator equation
$$\hat{A} \vert \psi \rangle = \vert \phi \rangle $$
$ \vert \psi \rangle$ is a complete set of orthogonal basis, thus, they are expanded
$$\vert \phi \rangle = \hat{A} \vert \psi \rangle = \hat{A}\sum_i \vert \xi_i\rangle \langle \xi_i \vert \psi \rangle $$
Multiply for $ \langle \xi_j \vert$
$$\langle \xi_j \vert \phi \rangle = \langle \xi_j \vert \hat{A}\sum_i \vert \xi_i\rangle \langle \xi_i \vert \psi \rangle = \sum_i \langle \xi_j \vert \hat{A}\vert \xi_i\rangle \langle \xi_i \vert \psi \rangle $$
The terms $\langle \xi_j \vert \hat{A}\vert \xi_i\rangle $ are the matrix elements of the operator $\hat{A}$ respect to the basis states $\vert \xi_i \rangle$ and can write as
$$\langle \xi_j \vert \hat{A}\vert \xi_i\rangle = A_{ji}$$
Then
$$ \phi_j = \sum_i A_{ji} \psi_i $$
This can writes as a matrix:
$$\begin{bmatrix}
\phi_1 \\
\phi_2 \\
\phi_3 \\
\vdots \\
\phi_j
\end{bmatrix}
=
\begin{bmatrix}
A_{11} & A_{12} & \ldots & A_{1j} \\
A_{21} & A_{22} & \ldots & A_{2j} \\
A_{31} & A_{32} & \ldots & A_{3j} \\
\vdots & \vdots & \ddots & \vdots \\
A_{i1} & A_{i2} & \ldots & A_{ij}
\end{bmatrix} \begin{bmatrix}
\psi_1 \\
\psi_2 \\
\psi_3 \\
\vdots \\
\psi_i
\end{bmatrix}
$$