The year, make, model and engine info would help but a serious vacuum leak could do that.
Dirty fuel filter
to much of it can stop our system
There are several reasons an engine may stall while driving, here are three.The fuel tank is empty and the engine is starved of fuel.Not enough power to climb a hill causing a stall.Faulty or damp electronics on a petrol engine can also cause a stall.
What causes a 1997 Pontiac sunfire gt with a 2.4 liter engine to stall when stopped at a light
possible bad TPS, IAC, or ECT sensors
The crank sensor probably needs to be replaced.
More info such as the year and engine size would help.
Need to know the year and make, It would help answer.
Removing the oil cap with the engine running causes a vacuum leak in the positive crankcase ventilation. This causes too much air to enter the cylinders at once, which results in a stalling engine.
An engine may stall when put in gear due to several factors, including insufficient fuel supply, a faulty ignition system, or a malfunctioning clutch. If the fuel pump is not delivering enough fuel or if the air-fuel mixture is incorrect, the engine can lose power when a load is applied. Additionally, issues with the clutch, such as it not fully engaging or disengaging, can cause the engine to stall. Other potential causes include sensor failures or problems with the transmission.
The TPS (throttle position sensor) has gone bad on your throttle body.
Check for vaccuum leaks this could be your problem.