Clogged fuel filter: A clogged fuel filter can restrict the flow of fuel to the engine, causing it to stall. Check the fuel filter and replace it if necessary.
Faulty fuel pump: A faulty fuel pump may not be able to deliver enough fuel to the engine, causing it to stall. Check the fuel pump and replace it if necessary.
Vacuum leak: A vacuum leak can cause the engine to run lean, which can lead to stalling. Check for vacuum leaks and repair them as necessary.
Idle air control valve (IACV): The IACV controls the amount of air that bypasses the throttle body at idle. A faulty IACV can cause the engine to stall when put in drive. Clean the IACV and check for proper operation.
Throttle position sensor (TPS): The TPS sends a signal to the engine control module (ECM) indicating the position of the throttle. A faulty TPS can cause the engine to stall when put in drive. Check the TPS and replace it if necessary.
ECM: The ECM controls the engine's operation based on sensor inputs. A faulty ECM can cause the engine to stall when put in drive. Check the ECM for proper operation and replace it if necessary.
Note: These are just some possible causes. If you are unable to diagnose and fix the problem yourself, it is recommended to have your vehicle inspected by a qualified mechanic.