Your edit was reviewed by Community. As the Community is an automated process, i think there is no such validation to for checking valid code. But yes it checks for the valid code format. I assume that your suggestion was removed because you removed some part of the code which you thought as useless but Community took it as an invalid edit.
However you are correct at your side.
have a look at the following image,
The original question was like in the image, a code, then a line and again the code. Haresh has remove the upper part of the code but Community reject his suggestion. But the same question was when edit by the other user ( named Shruti ) she removed bottom part of the question ( both were same code spinet ) and this time it was accepted by the Community, i believe that Community is design in such a way for Approval and Rejection.
For the direct editing question and answer you require 2K reputation. Users having such or more reputation can edit the post without peer review. This is the reason when the user after you, who did editing, his edit get accepted, because he as 4K reputation.