What gamma correction does, with numbers
Every pixel of a photo stores its red, green and blue as numbers from 0 to 255. A gamma correction puts each of those numbers through the same curve. Divide the value by 255 so it runs from 0 to 1, raise it to the power 1 divided by gamma, and multiply by 255 again. Zero to any power is zero, and one to any power is one, so black and white never move. Everything between them moves, and the middle moves most.
Some numbers make it concrete. With Lift shadows, gamma 1.8, a dark value of 64 becomes 118 and a mid value of 128 becomes 174, while a light value of 200 becomes only 223. The shadows nearly double and the highlights barely change. With Brighten midtones, gamma 1.3, the same three values become 88, 150 and 212: a gentler lift. With Deepen midtones, gamma 0.75, they become 40, 102 and 184, so the picture gets richer and darker without its whites turning grey.
Compare that with a plain brightness slider. Adding 50 to every value lifts 64 to 114, but it also pushes 220 to 255, and every value above 205 becomes the same flat white. Detail in clouds and skin highlights is lost. Black becomes 50, a dull grey. Gamma avoids both problems, which is why photo editors use a curve, not addition, for this job.
Auto balance works out the gamma from the photo itself. It takes the average brightness, using the Rec. 709 weights that match how bright each colour looks, and solves for the gamma that would carry that average exactly to mid-grey. A dark photo with an average of 60 gets a gamma of about 2.09, and a pixel at 60 lands on 128. Auto stays between one third and 3, so a photo of a night sky is not stretched into grain.
The limits are worth knowing. Gamma cannot recover detail that was clipped when the photo was taken: a burnt-out white sky stays white, and pure black shadows stay black. Lifting the shadows a lot also lifts the noise in them, so a phone photo taken in the dark may look grainy afterwards. The same curve is used on red, green and blue, so colours keep their balance but may look a little less saturated after a strong lift. JPEG files are saved again at high quality, HEIC comes out as PNG, and the largest image the tool takes is 24 megapixels.