General anesthesia works largely by disrupting the brain's ability to form new memories, so events during surgery are often never stored at all. Drugs such as propofol and midazolam act on receptors involved in memory encoding, especially in the hippocampus, which is the region that turns recent experiences into lasting memories.
Some patients do recall fragments of surgery, a phenomenon called anesthesia awareness, but it is rare and usually happens when the drug dose is too light. Even then, the memories are often vague or fragmentary because the drugs interfere with the brain's consolidation process, the mechanism that stabilizes memories over time.