There are two basic types of weight loss surgery: restrictive surgeries and malabsorptive/restrictive surgeries. They help with weight loss in different ways.
Restrictive surgeries work by shrinking the size of the stomach and slowing down digestion.
A normal stomach can hold about 3 pints of food. After surgery, the stomach may at first hold as little as an ounce, although later that could stretch to 2 or 3 ounces. The smaller the stomach, the less you can eat. The less you eat, the more weight you lose.
Malabsorptive/restrictive surgeries change how you take in food. They give you a smaller stomach and also remove or bypass part of your digestive tract, which makes it harder for your body to absorb calories.
Doctors don't do purely malabsorptive surgeries -- also called intestinal bypasses -- anymore because of the side effects.