How it is possible that a ket precedes a bra in a matrix expression? Is it possible to rewrite $\langle a| M|b\rangle$ as $|b\rangle \langle a|M$?
 A: The expressions you write are extensions in infinite-dimensional Hilbert space of plain matrix expressions.
Their analogs for finite dimensional real vector spaces and their matrices  indexed by a finite set of indices i,j, whose repeated form implies summation over the whole set, are
$$
|a\rangle ~~\mapsto ~~ a_i \\
|b\rangle ~~\mapsto ~~b_i\\
M~~\mapsto M_{ij}\\
\langle a|M|b\rangle ~~\mapsto a_iM_{ij}b_j , ~~\hbox{ a scalar},\\
|b\rangle \langle a|M   ~~\mapsto ~~  b_j a_i M_{ik}, ~~\hbox { a dyadic matrix,} \leadsto \\
\operatorname{Tr}(|b\rangle \langle a|M ) =\langle a|M|b\rangle  ~~\mapsto ~~ a_i M_{ij} b_j  .  $$
A: Thinking in component form makes it easier to predict what kind of objects you will be getting out of Dirac notation. The expression $\langle a|M$ gives
a bra (row vector):
$$\begin{pmatrix}a_1^*& a_2^* \end{pmatrix}\begin{pmatrix}M_{11} & M_{12}\\ M_{21}&M_{22}\end{pmatrix}=\begin{pmatrix} a_1^*M_{11}+a_2^*M_{21} &a_1^*M_{12}+a_2^*M_{22}\end{pmatrix}$$
If we define $\langle c|=\langle a|M$ then your question becomes "is $\langle c|b\rangle$ the same as $|b\rangle\langle c|$?" They are not the same; the first expression is a scalar
$$\langle c|b\rangle=\begin{pmatrix}c_1^*&c_2^*\end{pmatrix}\begin{pmatrix}b_1\\b_2\end{pmatrix}=c_1^*b_1+c_2^*b_2$$
while the second expression is a linear operator (matrix):
$$|b\rangle\langle c|=\begin{pmatrix}b_1\\b_2\end{pmatrix}\begin{pmatrix}c_1^*&c_2^*\end{pmatrix}=\begin{pmatrix}b_1c_1^* &b_1c_2^*\\ b_2c_1^*&b_2c_2^*\end{pmatrix}$$
Heuristically you can see that $|b\rangle$ expects a bra on the left while $\langle c|$ expects a ket on the right. So the expression $|b\rangle\langle c|$ expects a bra on the left as well as a ket on the right.
A: In general, you cannot rewrite $\langle a | M | b \rangle$ as $|b\rangle \langle a| M$. You can see that the two are not the same by just comparing what type of mathematical entity they are: $\langle a | M | b \rangle$ is a matrix element (of the operator $M$), which is a (complex) number. On the other hand, $|b \rangle \langle a|$ is an operator, as is $M$, so the product of the two is another operator, which is represented by a matrix, not just an element of one.
