I've been trying to understand the algebra behind:
Is there an equivalent of PEMDAS for matrices?
Even if I assume $(y^T-X^TB^T)(y-XB)$, I get $y^Ty-y^TXB-X^TB^Ty+X^TB^TXB$ which does not equal the above.
To get the above result, I used the following properties:
$(A+B)^T = A^T + B^T$ and assumed there is still a parenthesis wrapped around it. (PEMDAS Question)
$(A+B)(C+D)=(AC+AD+BC+BD)$ by multiplication and distributive property.
What above simplifications am I missing?

It is $(y-XB)'=(y'-B'X')$
The order of $XB$ has to be interchanged when you transpose it.
Multiplying out the brackets of $(y'-B'X')(y-XB)$
$yy'-y'XB-B'X'y+B'X'XB$
$y'XB$ is a scalar. Thus $y'XB=B'X'y$
$yy'-2y'XB+B'X'XB$
Remark
Let $X$ be a $m\times n$ matrix and $B$ a $n\times 1$ vector. Then $X'B'$ wouldn´t work because $X'$ is a $n\times m$ matrix and $B'$ a $1\times n$ vector.