For the type of dynamics you have with Lagrange [or the Hamiltonian] you find things tend to their place of minimal energy [or maximal sometimes like in optics], Causality is not at all the determining thing.
This is something I have already mentioned this in terms of the Kant Friesian School. Where causality is not a part of things in themselves.
I might add to this that time also is secondary as we see in Quantum Mechanics. [As Lemaitre wrote almost a hundred years ago in his papers showing the Big Bang and that time only began after there were a few quanta around to make time to be able to exist.]
And this also goes with the Kant Fries approach where time itself is not a part of things in themselves.,