Above you can see my Scratch workspace where the ship on the left is upside down when it is running, and IT IS THE SAME CODE.
Is it a bug of scratch or some kind of other problem?
I use Scratch 2 for kids programming classes and as a beginner at this object, at first I had the same problem that confused me a lot as to what would provoke the Sprite to turn around.
It turned out that Scratch makes the character rotate when it bounces off the edge (I guess that the reason is not functional).
Anyway to solve it I added the move->set rotation style (don't rotate)
before (the position doesn't matter, could as well place it after) the if on edge bounce
block.