Dyeing is a relatively simple and low-tech process. You take some fibre -- whether it's in the form of unspun top or roving, or spun yarn -- and you either dump it in a vat of coloured liquid or you pour coloured liquid upon it. You wait a while, you rinse the gunk out, you hang the fibre to dry, and you're more or less done. There are numerous variations on this theme, but the basic principle remains the same.
When dealing with natural fibres, which is to say animal fibres like wool and alpaca, or plant fibres like cotton and linen, the process remains more or less unchanged even if you are creating products on a massive scale. (The same doesn't go for acrylic and other artificial yarns, which are coloured by different processes; these fall beyond the scope of this writeup.) To oversimplify just a bit, it's simply a matter of how large a vat you use when you're dyeing your yarn.
However, dyeing is more an art than a science: no two batches of dye turn out exactly the same, no matter how carefully they are mixed; and sometimes even when the same batch is used twice, the yarn looks slightly different from vat to vat.
This is why the knitter needs to keep track of which batch of dyed yarn she is using for a project. Even if she is sticking to a single colourway, the yarn might look different when she switches skeins.
In knitters' parlance, each batch of dyed yarn is called a dye lot. Most yarn manufacturers stamp a number or a date representing the dye lot on their labels; depending on the size of the company, one dye lot may provide the market with ten skeins or with a thousand.
If you are planning to make a large project, like a sweater or a rug, it is wise to make sure that all the yarn you buy belongs to the same dye lot. If you don't, the colour might change slightly (or not so slightly) when you change skeins. Trust me when I say that a sweater made with three almost-but-not-quite-identical greens looks amateurish and sloppy. Trust me also when I say that these changes are not generally visible when the yarn is still in the skein: for some reason, yarn that looks identical on the table can turn out hideously mismatched once it is knitted up.
The effect of different dye lots is most obvious when working with variegated yarns. This may seem counterintuitive at first -- isn't the entire point of variegation to use multiple colours within a project? -- but it turns out that there is a significant difference between colour changes within a dye lot and colour changes between dye lots. Kettle-dyed yarns with gradual shifts in colour might also change palettes subtly across dye lots. Solid colours look worst of all when mismatched, though huge companies like Patons and Lion Brand sometimes claim that their batches are big enough to guarantee that your colourways will match no matter where in the country you purchase your yarn.
Like all rules of thumb, these rules have exceptions. Sometimes yarn of different dye lots looks fine when it's knitted up. Whether that risk is worth taking with your project depends on how much you value your time and how little you care about the final appearance. Every knitter has been forced to straddle dye lots from time to time, whether it's through bad planning on the part of the knitter herself, or poor yarn budgeting on the part of the author of the original pattern. Sometimes the result is okay, but usually it's a disaster.
Less often, there are situations where the label declares that two skeins come from the same dye lot, but they look dramatically different from one another when knitted up. In these cases, there's nothing for it but to frog and start over. Alas, this is an idea that all knitters eventually have to get used to.