Black is controlled by genes at the E locus. EE and Ee are black; ee is chestnut. All horses are genetically black or red (with red being chestnut/sorrel), and other genes modify the expression of those colors, diluting them, or adding white markings.
A black horse is black over its entire body, except for any white markings that may exist. Some horses that appear black have reddish-brown tinting in the hair around their muzzle, eye, flank, and behind the elbows. These horses are not black; they are usually called "seal brown" (more on this in the bay section). True chocolate brown -- not reddish-brown, but the color of a chocolate Labrador Retriever, with chocolate brown skin -- is extremely rare in the horse. The gene for this color is not present in most horse breeds.
There are two types of black. Ordinary black horses (Ee) will fade to a rusty brownish color if the horse is exposed to sunlight on a regular basis. The other type of black is called Jet black or True black (EE); it is a blue-black shade that is fadeproof.
Sorrel
Chestnut and sorrel are essentially the same color ee, genetically speaking. These horses are red, yellowish red, or reddish brown, and they do not have black points (the points being the mane, tail, and lower legs). Chestnut and sorrel are determined by genes at the E locus. Horses that are ee at that locus are chestnut/sorrel; horses with an E gene at the locus are black (absent other modifiers). Chestnut is recessive to black, meaning that a chestnut bred to a chestnut will always produce a chestnut foal. Two blacks bred together can produce a chestnut foal if both blacks are heterozygous (Ee). In that mating, there's a 25% chance of a chestnut foal, and 75% chance of a black foal. A black horse who is homozygous (EE) will only produce black foals
The difference between chestnut and sorrel is somewhat controversial. Some people call the redder versions sorrel; some call the redder versions chestnut. Some people (such as me) call the horses with flaxen manes and tails sorrel; some do not. Some people use one term or the other for all red horses. Some consider sorrel a term for horses who are ridden western, reserving chestnut for horses ridden English. Some breed registries use only chestnut or only sorrel; some use both.
Bay
Bay horses are identified by having a reddish brown body and black points (mane, tail, lower legs). The bay color is caused by genes at two different loci, A and E. The presence of the E gene codes for black color, and the A gene restricts the black color to the points. So bay horses are called A_E_.
Black horses have no A gene; they are aa at the A locus. Their genotype is aaE_. Lack of the A gene allows the black color to "spread" over the entire body; the presence of the A gene restricts the black color to the points.
Chestnut horses can carry the A gene, but since they have no black pigment (ee), they will not display evidence of the A gene if they carry it. An aaee horse and an A_ee horse look the same; both are simply chestnut. An A-ee chestnut can, if bred to a black (aaE_), produce a bay foal (A-E_), if the black parent passes on one of its E genes.