Fuel pump
Testing of the fuel and ignition systems is in order. Intermittent problems need testing when the problem is present, otherwise it won't help find the problem.I would start by checking for spark on a spark plug wire (or two or three plug wires, in case it may be a bad coil), during those times when it won't start. You need to see a blue, snapping spark to verify ignition system is working.To check the fuel system, have the fuel pressure checked, and the injector circuit checked. Good that you hear the pump, but you don't know if fuel pressure is correct, or if fuel is getting into the cylinders. One short test is to spray starting fluid or carb cleaner into the intake while engine is cranking. If engine fires up for a few seconds, you know it is a gas related problem.If ignition system is the intermittent problem, could be failing coil or coils, ignition module, crank position sensor, even the computer, or a wiring problem like a bad connection. Testing of each component will be required, or you could start throwing new parts at it, like many people do, until you find the bad part. Find a reputable mechanic-there still are a few, lol.