Once, I read somewhere (hence, this is may be a duplicate post, but I cannot find no one else reporting it right now) this problem is because when you paste something on StackExchange sites, an entry on the undo list is not created for the pasted item, then, when undoing the last thing, it will undo the pasted item and some other things you did before, i.e., the last undo event on the stack.
Other sites I use as GitHub, does not have such problem. This undo thing problem has become extremely annoying after years using StackExchange sites. I never seem anything close to this behavior anywhere else in the world so far. If you know something else which also has this "feature", please, comment.
I am not sure if this is a bug or if it is like this by design. If it is by design because someone which works on StackExchanges likes it (I am definitely not sure why they like it), then, this post would be a feature request for an user's setting, allowing us to change this really "awesome" feature.
In case someone thinks I am trolling, here is a video reproducing the problem:
If you need more detailed instructions, videos or tutorials about how to reproduce this awesome "feature", please, do not hesitate to ask!
Here, I am using Google Chrome:
Version 70.0.3538.110 (Official Build) (64-bit)
If you think GitHub is also bugged/broken like this, here is another video showing you I am not trolling and GitHub works wonderfully:
More fiercely, using the GitHub interface, let us call the next video as an expected behavior for StackExchange websites editor:
Re-posting here again, the Actual Behavior of StackExchange Websites, so you can closely compare both, Expected Behavior versus Actual Behavior: