You are not actually adding light, you are simply enhancing what little light you gathered. With a JPEG, "stretching" or "pushing" and "attenuating" are all done in the camera, and those enhancements are baked into the JPEG file, which is then lossy compressed and stored in a low precision format (8-bpc, 0-255).
With a RAW image, you are storing the original sensor data as it came off the sensor, without any enhancement, with lossLESS compression, in a higher precision format (14-bit, 0-16383). A RAW image is stored in a linear form, however camera settings are stored in the header as "metadata", such that when you load the image in DPP or Lightroom or any other RAW editor, it will look similar to a JPEG made with the same settings. However the actual pixel data in the RAW file is not actually modified by these settings, it is only "rendered to screen" with them, so you can see the image as it was intended.
Because the underlying data is not modified, and because it is stored in a higher precision, you have more freedom to shift the exposure around with software. You can push the shadows, pull the highlights, and adjust exposure, white balance, enhance the color, fix vignetting and a whole range of other image aspects without losing much in the way of definition or fidelity in the final result.
It should be noted that pushing shadows in an image that was underexposed is not the same as properly exposing that image. A pushed underexposed image will have more noise, because the signal strength was weaker. To have less noise, you need to expose more, so you gather more light, which improves signal strength. A strong signal has a higher SNR, and thus appears less noisy.
It should also be noted that if you are working with a scene that has high dynamic range, you may have some parts of your scene dark, possibly appearing overly dark on screen, whereas in real life those regions did not look as dark, as noisy, nor as devoid of detail. This is where camera dynamic range plays a role. A camera with 10-11 stops of DR will have more limited ability to have "shadow" detail pushed to restore realism, whereas a camera with 13-14 stops will have an extended ability to have "shadow" detail pushed to restore realism. The difference between such cameras (say a Canon 5D III and a Nikon D810) is the read noise and dark current. The Nikon camera has less of both, significantly less read noise (at low ISO), thus allowing shadow detail to be pushed more with less noise.