Technically we don't know whether general anesthesia actually prevents you from feeling pain, or whether it just prevents you from forming memories. As far as I know at least.
General anesthesia is usually a combination of multiple drugs. We know exactly what each drug does, medical science isn’t so good at explaining why the drugs have these actions. anesthetists combine these drugs to suit the requirements of the procedure and the patient
Anesthesia usually includes drugs with distinct, separate actions, like an analgesic (to block pain receptors), muscle relaxants (so patients can be moved/organs accessed), CNS depressants (to prevent unexpected spasms disturbing the surgeon), coma-inductors (so patients don’t chat with the staff and freak them out after practicing on cadavers for years), and amnesia-inductors (because surgery is kind of gross).
We know enough about them to use them safely, but most anaesthetic drugs are somewhere on the spectrum from "not fully understood" to "a complete mystery". Science knows how anaesthesia works in the same sense that I know how a car works - I can push the pedals and turn the wheels with sufficient proficiency to get to the grocery store in one piece, but I'll be damned if I can explain what's happening under the hood.
I guess that's technically correct, in that it's difficult-to-impossible to "know" about someone else's subjective experiences.
On the other hand, painful stimuli tend to (e.g.) increase a person's heart rate and blood pressure, and that the proper anesthetic plane blocks those responses, so it's clearly doing something in the moment. What we don't know every well is the mechanism of action for general anesthetics.
I would imagine that we must know that by now. We should be able to just see on a brain scan whether the pain centers are lighting up in response to pain.
Anesthesia usually includes drugs with distinct, separate actions, like an analgesic (to block pain receptors), muscle relaxants (so patients can be moved/organs accessed), CNS depressants (to prevent unexpected spasms disturbing the surgeon), coma-inductors (so patients don’t chat with the staff and freak them out after practicing on cadavers for years), and amnesia-inductors (because surgery is kind of gross).