If the answer was wrong, and the edit makes it (more) right, then approve the edit. This is exactly why suggested edits were introduce: to improve good-but-not-perfect answers.
If the answer was completely wrong and correcting it is impossible without completely rewriting it, don't edit, but instead downvote (and, preferably, post a comment to explain the error in the answer if there isn't one already) and post a competing answer.
If the edit is a matter of style or recommendation rather than a matter of correctness, then reject it. If you think the issue is important, comment on it. Generally speaking, don't correct an answer that's not actually wrong.
Don't edit code in questions unless you're absolutely sure that the error in the code is not part of the confusion. That's pretty much never. The exception is whitespace (especially indentation).
In this particular case, I don't know the subject matter, so I can't tell whether the original answer was wrong (in which case the edit should be accepted) or merely suboptimal (in which case the edit should be rejected).