You're right that sleep and general anesthesia are very different, and general anesthesia in fact actively inhibits the glymphatic circulation that clears waste products from the brain). Since most of are able to pull an all-nighter and except for problems with memory, focus etc, be OK after a couple of days' catch-up sleep, the sleep deprivation isn't an acute issue -- after all, folks after major surgery tend to sleep a lot anyway, as the body needs extra sleep during healing.
As far as preventives, there is an ongoing study to see whether pre-operative cognitive training can reduce the odds of post-operative delirium, one of the ways in which temporary post-surgical cognitive dysfunction can be visible.
More seriously, there may be long-term costs of surgery, with or without anesthesia, on cognitive reserve. This is well-known for cardiac surgeries, but may also be true for any surgeries, as a cross-sectional study found that even the lifetime number of non-cardiac surgeries one's had, correlates with reduced verbal learning and memory in one study of healthy older adults.
The general issue, called Post-Operative Cognitive Dysfunction (POCD) is an active area of investigation for older adult care. There seem to be multiple suspects - from inflammation to brain hypo-perfusion -- and each will suggest steps that can reduce the risk. A recent review is Current Perspectives on Postoperative Cognitive Dysfunction in the Ageing Population.