A buildup of lactic acid, which results as muscles burn glucose for energy, causes the short-term muscle "burn" you get during exercise.
The days of soreness that follow intense activity are caused by microscopic tears in the muscle fibers and the tissue that connects the muscles. The greater the effort, the greater the tearing, and the greater the ache.
The good news is that this is a natural part of muscle behavior and not an injury. Allowed to rest, the muscles will repair the damage and in the process get bigger and stronger in anticipation of having to repeat the effort.
To build muscle, you have to repeat this process of tearing-and-repairing. Athletes typically do not work the same muscle group two days in a row in order to give the muscles time to repair themselves.
While stretching before exertion is almost universally encouraged to prevent injury, it may offer little or no reduction in DOMS. Similarly, massage and cool-down periods following an intense workout do nothing to shorten recovery time.