What is happeninggggg~~~~~
I figured it out!
Sort of spoilers below?
This is my best guess (please confirm @epicpikaguy)
The game is trying to make a flag with greater than 9 steps. Since the game won't let you have more than 9 steps, it freaks out and gives you a negative number corresponding to the positive number. (which is why if you continue far enough, the step counter will be -65525, *blank*, 9, 8, and so on.) Next, the game tries to make an image on the flag for the number. Since it can't find a dot image, it searches in the game image database and finds another image, which it places on the flag. I still have no idea why the game is trying to make a higher than 9 step flag. (For confirmation help, the "wormhole" flag gives 24 steps.)
Your synopsis seems to be more or less correct, from what I can gather. Here's a relevant comment in the game's code (encoded in rot13): "[n fgrc pbhagre inyhr gung vf] terngre guna 10 zrnaf vg ercerfragf (inyhr-0kssss-1) fgrcf (juvpu raqf hc orvat artngvir.)"
(The game's codebase is so large that I keep having to re-remember how certain parts work, which is why comments like these come in handy.)
As for the images on the flags (I'm simplifying here but it's basically correct): the game stores image indices in a giant list, and the flag "pip" images are stored together. E.G. there's an image for one dot, followed by an image of two dots, and so on. Normal flags don't have values greater than 9, but when glitch flags do, they try to access e.g. the 20th dot image, which ends up being a different image entirely since the indices are stored next to each other.