Wooden doors warp due to the moisture content of the timber used in their manufacture, and the rate at which they dry out. Its impossible to stop, but you can minimalise things by choosing a door that has been kept flat in storage for a while - squint down both long edges to check for warping, buy it if its flat, and hanging the thing as soon as you can.
John, July 2008