Let us start with the usual Euler Lagrange equations, and impose $L=L(q)$ only-$$\frac{\partial L}{\partial q}=\frac{d}{dt}(\partial L/\partial \dot{q})$$, and the RHS becomes zero, implying $$\partial L/\partial q =0 \implies L(q)=const$$, so in fact the Lagrangian is something trivial. In the field theory case, a similar thing happens obviously $$\frac{\partial L}{\partial \phi}=\partial_\mu(\frac{\partial}{\partial(\partial_\mu\phi)}L)$$, and imposing $L=L(\phi)$, one gets $$\partial L/\partial \phi=0$$, a similar result.
Now things get worse. Take, say, $L=\phi(x^\mu)$(imagine the appropriate dimensional constant is unity). Clearly, $\partial L/\partial \phi\neq0$ here!Then, on switching the partial derivatives on the RHS of the E-L equations(with $L=\phi$), we get $$\frac{\partial \phi}{\partial \phi}=\partial_\mu(\frac{\partial}{\partial(\partial_\mu\phi)}\phi)=(\frac{\partial}{\partial(\partial_\mu\phi)}\partial_\mu \phi)$$, which is correct, it simply says $1=1$. But had we NOT switched the partial derivatives, we would have gotten $$\frac{\partial \phi}{\partial \phi}=\partial_\mu(\frac{\partial}{\partial(\partial_\mu\phi)}\phi)\implies 1=0$$
A similar problem can be seen in the point particle case too.
My question is, why does the order of partial derivatives screw everything up here? On the one hand, the E-L equations imply $L$ will be a constant if we choose it to depend only on $q$ or $\phi$. But simply switching the order of derivatives now allows us to consider a non-constant $L$, as the example shows.
What am I missing here?