Look carefully at the saddle in your guitar. It is not placed in a straight line but angles backwards from the treble (thinner) to the bass (thicker) strings. The thicker the string, more is the length required to flatten it.
Also, when you play a string on a (any) guitar, by fretting it, you elongate it, even if it is very slightly. This causes the note to go sharp. To ‘compensate’ for the sharpness, changes are made, mostly to the saddle but often to the nut as well.
All the methods used to make a string play the same at every fret and in relation to each other is intonation and is the last step in the setting up of your guitar. Ideally, what you are looking for is for an open string to play a note and for the SAME string to play the SAME note – an octave above – when fretted at the 12th fret.
Why 12th fret? Because from the nut to the 12th fret is half the length of the string and from the 12th fret to the saddle is the other half of the string – making the 12th fret the midway point of a string.
So, during a set-up, if the 12th fret note is flat, the point of contact on the saddle with the string is moved forward a little. If the 12th fret note is sharp, the point of contact on the saddle with the string is moved back a little. And the process is repeated till your tuner (or your ear) tells you that the open and fretted note are the same.
What this effectively does, is increase or decrease the length of a string, thus affecting intonation.
How is this point of contact moved forward or backward? By filing the top of the saddle forwards or backwards. This is referred to as compensating the saddle (sometimes even the nut). And thus, intonation is often also referred to as compensation.
Look at the picture below. The ‘straight’ saddle is how a traditional saddle on an acoustic guitar used to look. Later, as saddles started getting compensated, they began to look like the second one. Still later, they were changed to look like the third one.
In some cases, they look like this:
In some cases and models, the saddle is actually inserted in two parts to get the intonation correct.
And in rare cases and models, the saddle is not one or two pieces but six small pieces to get the intonation near perfect!
Once you have made all possible adjustments to the saddle and find that the guitar is still not intonated properly, then you turn your attention to the nut of the instrument. Nuts too are compensated by adding material to the nut, taking material away, or fashioning a nut (out of bone, Tusq, corian, etc) to have extra material.
Here is one with some fibre used to shorten or elongate the length of a particular string.
And this one uses bone for intonation.