The process should be straightforward. An injection sends you off to sleep, a gas keeps you asleep and you wake up at the end when the gas is turned off. Many operations need full muscle relaxtion so the surgeon can do a proper procedure. To achieve this muscle relaxants are given. They stop all the muscles from working.
Anaesthesia In Action
However if there is a problem with the gas that keeps you asleep there is a risk you may be awake, unable to move and feeling the whole operation.
A recent study found 150 patients in 2011 who reported being aware during their operation. Out of the millions of operations carried out it's a tiny number but should be totally preventable. The trouble is that the true number may be much higher as there have been few studies looking for awareness. Hopefully that will change.