Car won't start

I have a 2005 Mazda 3. The car starts no problem after sitting for a while. If I turn the car off for only 5-20 minutes sometimes the car will not start again. After trying to start the car several times it will eventually start, it usually takes 1-2 hours, but twice it has started within five minutes. The lights, radio, and all power works but the engine will not turn over and the starter does not make any sound. The problem started about a year a half ago. First the dealership changed the battery, then said it was a frozen relay, and finally changed the starter. After they changed the started I did not have the problem until a few weeks ago. The problem has never happened while it was at the dealership. They have no idea what the problem is. Any ideas? Thanks for your help!