BoltClock's comment resonated with me.
I've been pondering this for a long time - not just with code in questions, but more broadly: what sort of edits are the responsibility of the post owner and not the community? (emphasis mine)
I've wondered the same, but ultimately I think that the guidance we give in the help center covers it:
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. The original author of a question or answer may always edit their own post, regardless of reputation level.
Edits are expected to be substantial and to leave the post better than you found it.
The balance for that power is provided as of the Reject Reasons when reviewing Suggested Edits:
This edit deviates from the original intent of the post. Even edits that must make drastic changes should strive to preserve the goals of the post's owner.
So what does this say about editing responsibility?
I take that to mean that if an edit will change the meaning of a question, it is the responsibility of the OP, except in rare border cases. (e.g. Significant generalization of a question to improve its effectiveness as a canonical post.) On a site with programming questions, code tends to be the core of the question - the clearest expression of intended meaning, which is why so many of us will leave non-superficial code changes to the OP, and will reject suggested edits that don't conform.
On the other hand, the community is responsible for any edits that improve the post without changing its intended meaning. Remembering that the OP is part of the community, though, they share that responsibility, so if you have an opportunity to improve your own post, you should be first in line to do so, as it can only help you get the answer you need.
If you're going to cross the lines of responsibility by changing the intended meaning (read: code), then getting permission to do so is absolutely appropriate. Code changes without prior permission should only be done when community security is affected. (Examples: Clear copyright infringement, malicious code, or code containing sensitive private information.)