There are basic rules about editing in the help center. Quoting the relevant parts:
When should I edit posts?
Any time you see a post that needs improvement and are inclined to suggest an edit, you are welcome to do so. (…) Common reasons for edits include:
- To fix grammar and spelling mistakes
- To correct minor mistakes or add updates as the post ages
When it comes to code, do fix simple syntax or logic errors. The basic idea is that you should try to make the post be the way the original author intended. Usually the original author intended the code to work, so if you notice what is clearly an error, fix it. This includes missing parentheses, typos in variable names, missing arguments to a function, etc.
Do respect the author's style. For example, don't go and change the original author's variable naming conventions. Don't rewrite the code using a completely different package.
General rules can't cover every case. For example, removing a dependency on a third-party library or recent version of Emacs can be a good thing if it affects a tiny part of the code, or a bad thing if it requires a complete rewrite of a function. Use common sense.
In all but a narrow set of circumstances, the original author gets the last word. (Exceptions include adding attribution for non-original content, and egregiously dangerous advice that warrants a clear warning.) If the original author rolls back your edit, move on. If you really don't like the author's version, you can downvote (if a post has been edited, you can change your vote on it). If you think your edit matters, you may want to post an answer of your own, giving credit to the original author if you copied part of their code.
As an author, if someone makes an edit that you don't like, roll it back. You may leave a comment to the editor to explain why you didn't like the edit; if you write
@name-of-editor in a comment, the editor will receive a notification, even though the interface doesn't provide completion for editor names. Don't get into a rollback war: if the editor insists, flag for a moderator's attention and explain what is going on.
Don't delete your post because you didn't like someone's edits. Your post is still your own. Moderators may undelete self-deleted answers if they feel that the answer was useful — we don't like it when people take their marbles and go home.