When you put it in Drive you can't hit the gas or it dies or lugs until you turn it off and try again, and only on occasion does it not act up.
My car has an automatic transmission.
This may be a failing throttle position sensor. This is a unit that monitors the position of your foot on the gas pedal and relays this to the computer. The computer adjusts the fuel supply to the engine based upon the position of your foot. When this sensor is not working properly, this may cause the symptoms you have described.
I would recommend having an expert mechanic, such as one from YourMechanic, come to your home to diagnose your car and replace the throttle position sensor if necessary.
Our certified mechanics come to you ・Backed by 12-month, 12,000-mile guarantee・Fair and transparent pricing