States are kind of like git commits. Just like git commits are a snapshot of a repo's filesystem, Code Mirror states are a snapshot of the state of the editor. Any time you type into the editor or dispatch changes, a new state is generated. But if you saved an old state in a variable you can revert back to it.
Try making edits above, saving state, then loading a different state. Notice how the undo (ctrl-z) history is tied to the current state you are on and its ancestor states and not necessarly what you most recently typed!