2004 Hyundai Elantra GT - Weird key behavior

My car is Hyndai Matrix it switches off the engine while I’m driving. It starts again after about ten minute. The mechanic advised me to use a spare key. I drove about 100Ks with the spare. I did not have a problem, but the problem started again. I bought the car in 2014. It did not have the mobilizer. What might be the problem?

No such thing as a Hyundai Matrix . . . at least not in the USA

but there was a Toyota Matrix

Could be the ignition switch, will probably need a ‘hands on’ diagnosis rather than us guessing.
You left out a lot of information in your question. All we know is you have a 15 year old vehicle that was ten years old when you bought it. Sometime after you bought you switched to your second set of keys, then drove 100,000 miles, unless you meant you drove 100 km.