car starts sluggish then dies..

Well its happened once or twice…but this time it was kinda hard to get the car moving.

I just dropped off my brother to work and left the car off. Turned the car on, and then i feel the engine kinda getting sluggish and then just die.

Cranked her again, and the RPM’s would just go high then all of a sudden just drop.

THis time i applied some gas but it seems that it just dies out anyway.

So i left the car in 1st gear when turning on the car and it moved, surprisingly. and now there has been no problems since.

My question is how and why did that happen, and what are some ways of preventing it from happening again…