Since when is adding the code that was originally a link an invalid edit?
If you paste in code that was from a link, it's worth making it crystal clear that's what you're doing in your description, otherwise a hasty reviewer might just see a bunch of new code and say no.
Adding code that was in a link should be accepted if it's clear from the edit description that that's what happened. A diligent reviewer would check that the two matched.
The example you first gave had to had no link in the original, and it very much appears the user who suggested it found that code themselves.
Suggested edits are for changing how well a question or answer says something, not for changing what they say, so sadly edits like the one you originally linked to count as changing too much and will be rejected.
With enough rep (2000) users can edit without being subject to review. (And should also be more familiar with what the community's expectations are.) With this rep we trust people more not to vandalise something, so there's more freedom, but also more responsibility.
For suggested edits, please improve grammar, phrasing and spelling etc throughout the post.
Reviewer's aren't expected ever to make a judgement about the content, so edits shouldn't change the content/overall meaning.
The edit description was
That clearly falls into the category of an edit which changes to much or is an attempt to reply to or comment on the original. Those are standard reasons for rejecting edits.
It's going to be all about the edit comment here. I bring code and images inline all the time on sites where I don't have edit privs, and my comment is
(or image, obviousy) The reviewer can then see that a link has been removed and 20 lines of code has been added, and approve. An especially good reviewer can follow the link to see if I brought in the right code. These edits of mine are always approved.
But if the comment is
Then (switching to my reviewer hat) I would reject that edit.