Primer provides a protective, sealing coat to the door which prevents moisture ingress and should be applied to all surfaces of the door, including the top and bottom edges. Primer is used immediately before painting a new surface while undercoat, with which it is often confused, is used before painting a surface that has previously been painted.  An undercoat can act as a primer (there are many combined primer/undercoats on the market) but a primer is never an undercoat.
Most people buy unfinished, wood doors to enjoy the natural appearance of the timber, but of course, you can paint them if you desire. In this case, apply a coat of primer as a preliminary step.
If you are working on a primed internal door, then this step has already been taken care of for you, and the instructions which follow assume that this is the case. If you planed off some of the door to fit it, add primer first in these spots to ensure a complete seal.