How is this expression a valid lambda expression?
When in doubt, write down a lot of parentheses:
$$\lambda x . ((x ((\lambda y . ((y y) x)) x)) x)$$
and
$$\lambda x . ((x (x x)) x)$$
In $\lambda$-calculus there is the convention that $A B C$ is understood to be $(A B) C$, that is, application associates to the left. So, if somebody wants to $A (B C)$ instead, they have to put in some parentheses.