Engine Stalls During Shift To "D", "3", "2" &/Or "R"
WARNING: This page is about a different car, the 2002 Mazda MPV. However, it is still accessible from the selected car via links, so may be relevant.
Malfunction is most likely engine control related (IAC system). Otherwise, fault is in input/turbine speed sensor (engine sometimes starts) or TCC piston circuit (engine always stalls).