Sometimes my truck will turn over but won’t start. If I wait about 10 minutes, it starts right up. This happens sometimes before it has run at all and sometimes after it has been run.
It is best to provide full info on the vehicle including year, engine, mileage, and basic info about maintenance history.
The next time it won’t start, blow some starter fluid into the intake. If that gets it to fire - even briefly - then you troubleshoot the fuel system. Start by putting a pressure gauge on it and watch what it does after you shut it down and as you try to start it.
If the starter fluid has no effect, check for spark - a spare plug or spark tester are easy to use. Then you’ll know whether to chase a spark or fuel problem.