Anesthesia routinely involves the use of paralytics, which are separate from drugs used for analgesia (opioids or local/regional blocks) and inducing unconsciousness (propofol, anesthetic gasses). This can lead to situations where someone is paralyzed, their pain is under control (as observed by blood pressure), but the gas or propofol is insufficient to actually induce unconsciousness. Some of this comes down to individual physiology. Some of it is probably mistakes in anesthesia management.
Amnesia comes into this with the use of benzodiazepines. They can reduce anxiety before surgery. Or even during surgery if the patient needs to be awake. As a bonus, they can prevent memories from forming. Propofol can also cause amnesia, but it is primarily used to suppress consciousness.
One of the most terrifying things I’ve heard (from a final year med student, who was present in many surgeries) is that many patients under anesthesia react to pain. They move away from the knife, sometimes they make sounds as they’re being cut, etc. They just don’t remembers any of it afterwards.
I’ve had a few surgeries in the past and didn’t think anything of it, but now I kinda dread surgeries.