Audio data is stored on the CD as a series of bumps and flat spots arranged in a tight spiral pattern that starts at the inside of a CD, and works its way outwards, just like an old vinyl record/LP. You can find more details about the inner workings of a CD/DVD drive here.
Even a small scratch across the spiral data track on the surface of the CD appears huge to the super-fine read laser and optical sensor assembly in the CD player. Depending on the size of the scratch, it may be enough to make the CD player accidentally think that it needs to move the sensor further than it should in order to stay 'on track'; this extra movement actually causes it to lose the spiral once the scratch has gone by, and all of a sudden the CD player needs to go search for the spiral again. Sometimes, it finds it again so quickly that you don't even notice. Other times, it 'thinks' it finds it, but actually ends up 'skipping' either forward or backwards in the actual song. This, you will indeed notice. And, if it really loses its way, some CD players will even return to the 'zero' position and use the index information to move the head back to the approximate location where it lost the track, in the hopes of reacquiring it. That's when it seems like it is going berserk with the head assembly going back and forth, back and forth.
CDs use Cross-interleaved Reed–Solomon coding for error detection and correction. As mentioned in the article, "Reed-Solomon codes are specifically useful in combating mixtures of random and burst errors. CIRC corrects error bursts up to 3,500 bits in sequence (2.4 mm in length as seen on CD surface) and compensates for error bursts up to 12,000 bits (8.5 mm) that may be caused by minor scratches." Larger scratches as mentioned above will result in uncorrectable errors and skipping. When you burn a new CD, you obviously use the error-corrected data obtained from the original and so the drive no longer needs to perform error correction on the bad spots, plus of course skipping no longer occurs due to lack of scratches that would throw off the sensor and tracking mechanism.