Power goes on and off
Maybe.  The definitive test is to measure the voltage before the main breaker when the failure occurs.

If you are handy and knowledgeable enough about electric wiring, remove the breaker box panel cover.  Probe the main lead wires coming from the meter with a voltmeter or voltage indicator during an outage.

Note that opening the panel and taking a good close visual look at the leads upstream and downstream of the main breaker might reveal the problem.  Maybe there are discolored or loose wires, melted insulation, charring, a stray wire, etc.