Yes, the rollback was justified.
While we value both questions and answer posts on Code Review, we have found that answer invalidation (changes to the question that make the answers look wrong or disconnected) causes continuity problems in the Q&A format of the site.
As a consequence, we enforce the no-code-edits-after-answers-exist "rule" to provide clear guidance on what is allowed, or not.
Now, all rules will inevitably have exceptions, so your question here in meta becomes: Why can my edits not be treated as an exception since I tried hard to "retain the context"?"
The answer to that is that when people review code they do it in the full context of what you present. Their thought processes and observations will be different if the code is not (exactly) the same - even changing comments changes things.
The bottom line is that you cannot know what the person who answered your question would have done differently in their answer with the revised code.
As a small example of what could be different, in the one answer, they say "One simple refactoring for this method could be to simplify the following code block, that is used 9 times in the Method" ..... and, with your code changes, is that code block still used 9 times?
The answer is "No".
The rollback was very appropriate in this case, and your specific edits are not an exception to the rule.