Stalling corolla

I have a 2006 Toyota Corolla. The other day I was pulling out of the parking lot and it stalled. I tried to start it back up but it didn’t. I waited a while and it did start back up but the “check engine light” was on. I drove it around the block and it was ok. I checked to make sure the gas cover was closed and it was. The next day the light was off so I figured it was ok. Two days later I am pulling out of the parking lot and it did the same thing. When I tried to restart it it wouldn’t. It sounds like the engine isn’t clicking over and catching to start up. I am thinking and alternator, a starter, or an engine coil? Any ideas on what it is and what the cost is to fix it?

Go to most any major auto parts store and have them read the engine light code for you and report back. They’ll do it for free.

As in medicine, you can’t go from two small symptoms to a cure. It doesn’t work that way with human bodies, nor, with cars. But, if you want to do experiments, change all the parts you wish.
If you want a better method, you get all the symptoms you can find, and do a few simple checks; then, you can bring that here for worthwhile advice.