The next time it won't start; turn on the headlights and see if they are at normal brightness, or if they are very dim. If they are very dim; the battery has been discharged. This would most likely be caused by a bad alternator.; which could either not be charging the battery when the car runs, or could be draining the battery while the car is turned off. So you would first need to recharge the battery with a battery charger, and then drive the car to an auto electrical shop to have the alternator tested.
But if the headights are at normal brightness when the car won't start, the starter relay is probably defective. So I would replace the starter relay.