'04 Mazda 3 dies after it starts up

My engine dies after I start it up, but will run after I restart the car. What is going on?

If my car is parked for an extended period of time (e.g. overnight), then sometimes when I start the car up the engine dies. It does not die immediately though. I start it up, and the engine roars for a few seconds with the rev count at 2000 rev/min. Normally after those few seconds the rev count decreases to a bit less than 1000 rev/min but idle around there until I drive. However, sometimes the engine just stalls and dies. When this happens the dashboard lights up every warning sign. When I restart the car though everything is fine and I can drive it indefinitely. If I am anticipating the engine dying when I hear some sputtering, I floor the engine for a second and the engine ceases to sputter and runs normally. I replaced my battery and I just had a tune up, but the problem still persists. Unfortunately, I cannot demonstrate this to a mechanic since it is random and would only occur during startup after the car has sufficiently cooled down. What may be the problem, or what should I look out for?

try this cleaning video to fix it https://www.youtube.com/watch?v=NWCKvU2FmDc

Thank You Scotty! Ill give it a try. Also, my check engine light turned on indicating a problem with my thermal gauge. I replace it, but the check engine light still turns on every once in a while indicating a problem with it. Could it be an issue with the connection?