For example, in the case of deleting information, the easiest way to provide an undo function is to never really delete anything and just flag as deleted (something that doesn't free up storage, and if implemented without the users' knowledge, is abusive in terms of data privacy and ownership).
As for users not expecting the existence of an undo button in a web context, well, Gmail for instance has an "undo" link for lots of actions (archiving, moving to trash, etc.). I'm sure other web services provide similar things too.
I guess if it immediately gets soft deleted and in a maintainance batch gets purged. Until maint runs the undo link could still work (although it would still only display until they left the page).