1995 Chevrolet C2500 5.7L does this weird thing when put in Drive or Reverse. If it's not warm enough, it will shut off.

old age, try tuning it up and clean the fuel injectors. Pray it's not the transmission or torque converter starting to go out

Also try Scotty's video: https://youtu.be/NWCKvU2FmDc