There are a number of different ways - but the simple explanation, is that the original CD contains information that cannot be recorded by a conventional burner. The most advanced protection systems are used on CD-ROM discs.
The oldest systems simply had corrupted sectors on the originals (these sectors would be mastered with a deliberately incorrect error detection code). Burners of the time could only be commanded to write the actual readable data - they would automatically calculate the error detection codes so they would always be correct.
Later burners were able to record the entire sector including data, error detection codes and other information like subcodes, defeating this method.
The next advancement was the use of unburnable data sequences. Because of the way in which information is burned onto a CD-R, certain patterns of data produce a much stronger signal on the resulting disc. There are certain sequences that are difficult to burn and produce a very weak signal when the disc is played back. In a few cases, the burned signal is so weak that the sequence is not recognisable. All the software has to do is try to read the sequence off the disc - if it can't, then the disc is a copy.
To get around this, some software was able to detect these codes, and replace them with a similar, but stronger code, in order to keep the data readable. When newer burners came out, some had improved performance when recording these sequences.
The next major step was recording the data on the disc out-of-order. For example 0:00 to 1:59 would be recorded on the disc, then instead of 2:00 following straight on, the data would be recorded saying that it is 1:30. The idea was that if the drive was reading 0:00 and searched for 1:30 it would find the first 1:30 and read that, but if the drive was at 5:00 and searched for 1:30 it would find the 2nd (which could contain different data).
Blank CD-Rs come from the factory embedded with information which tells the burner exactly where to put each piece of data - many burners are, therefore, unable to write data in the wrong part of the disc, and will not be able to copy a disc such as the one above.
Protecting audio CDs is more difficult.
Early methods simply recorded garbage in unused parts of the 'table of contents'. Most audio players would ignore this, but many CD-ROM drives (or ripping software) would get confused and crash. This was not ideal, because it had major compatability problems with audio players, and did not stop all ripping.
Later methods recorded multiple sessions on the disc. Audio players only read the first session and ignore all others. CD-ROM drives always read the last session, unless specifically requested to read another. The protection worked by putting garbage in the last session, causing a CD-ROM drive or PC trying to read it to crash. Problems with this method were that some high-end CD players and some car head units are based on CD-ROM drives and would not play these discs. This method is also easily defeatable by using a marker pen or sticker to obscure the last session on the disc.
Another method worked by deliberately missing bits of data off the disc. Audio CD players are designed to cope with 'drop-outs' where they lose tracking of the disc. In the event of a minor drop-out, the audio processor fills in the gap, by guessing what should go there. Most of the time, this is inaudible. These discs would come with frequent drop-outs actually recorded on the disc. CD-ROM drives, when ripping the audio, generally don't fill the gaps - instead, the ripped audio is filled with static and pops. This method didn't suffer so much with compatability, but instead the discs are slightly less tolerant to scratches, and the sound quality is slightly degraded.
Another recent protection method uses a data session, which contains an autorunning program. This program installs itself on your PC, and will interfere with ripping programs if it detects its CD in your CD-ROM drive.