A text editor needs undo and redo. If actions are just function calls like insert(0, "Hello"), nothing remembers that the call happened, so nothing can be reversed. For a delete, the removed text is gone unless something stored it before it was cut.
The moment you want to take an action back, you need a record of the action itself, not only its effect. That record has to carry the arguments it ran with, and it has to know how to undo itself.