The situation could have several causes, so lets list them out.
1. The breaker could be failing, difficult to tell unless you can feel the breaker when it trips, not later to see if it is hot.
The other way, would be to move the wires to the water heater to another breaker the same size, like an electric dryer breaker.
2. It could be wiring connections at the breaker or in the water heater wiring compartment.
Inspections at both locations would show signs of overheating and possible connection damage.
3. One of the heating elements is failing in the water heater.
There are 2 elements and the top one heats first, then the power switches to the bottom for heating. Once the bottom has reached temperature, it switches back to the top.
Turning the thermostat completely down on the bottom may help to determine if it is the problem, that way the top will heat and then switch to the bottom, but the bottom will not heat due to the thermostat being off.
Unfortunately, you would have to monitor the situation to see what happens, so running the water to make the water heating to start is needed and the time to watch.
A multi meter tester helps to find out if the elements are failing with a continuity test and the easiest way to find the problem.
Those are the possibilities, the most common problem is one of the heating elements failing and needs replacing before it will trip the breaker instantly and lose hot water all together until repaired,
Let me know any questions, here to help as needed