First remember that each matrix element can be written as outer products in Dirac notation:
$$|0\rangle\langle 0| = \begin{bmatrix}1 & 0 \\ 0 & 0 \end{bmatrix},|1\rangle\langle 1| = \begin{bmatrix}0 & 0 \\ 0 & 1 \end{bmatrix},|1\rangle\langle 0| = \begin{bmatrix}0 & 1 \\ 0 & 0 \end{bmatrix}, |0\rangle\langle 1| = \begin{bmatrix}0 & 0 \\ 1 & 0 \end{bmatrix}\tag{1}.$$
This can be verified easily, for example:
zero=[0 ; 1], one=[1; 0]
one*zero'
gives:
ans =
0 1
0 0
So now let's write the matrix as a linear combination of outer products in Dirac notation:
$$
\tag{2}
\frac{1}{\sqrt{2}}|0\rangle\langle 0 | + \frac{1}{\sqrt{2}}|0\rangle\langle 1 | + \frac{1}{\sqrt{2}}|1\rangle\langle 0 | - \frac{1}{\sqrt{2}}|1\rangle\langle 1 |.
$$
This is what you have in your question, especially if you factor out the $|0\rangle$ from two terms and $|1\rangle$ from the other two terms 😊