It sounds like the cells that are running out-of-order may not actually be ordered.
marimo can't track mutations, so if you are editing a dataframe, you need to either edit it in the same cell in which it's defined, or reassign the dataframe to a new variable in each cell that it is edited.
If this is actually the problem, there is an explanation here:
https://docs.marimo.io/guides/reactivity.html#avoid-mutating-variables