Electric water heater thermostat keeps tripping and needing reset
Water heaters have replaceable parts in them: 


The anti-corrosion anode rods (what a boater calls a "zinc") 
The heating elements proper 
The dip tube which is an internal baffle which brings the cold water down to the bottom of the tank 


The dip tube needs further explaining. In stagnant water, hot water will rise to the top.  However if it were actively stirred, the temperature of the water quickly becomes the average of all the water in the tank.  As you use hot water, cold water comes in. If stirring were happening, the heater's water would continuously decline in temperature as you used it.  That would be no good! 

So the hot water tank is optimized to work more like a toothpaste tube - the entering cold water pushes the hot water upward -- so it doesn't stir or mix, but the hot water moves up like a piston until it is used up. 

The dip tube's job is to carry cold water to the bottom of the tank, so it can do the piston thing. Otherwise, cold water would just "take the shortcut" from the cold inlet to the hot outlet just 9" away. 

Your dip tube is broken, hence the flashes of hot and cold.  Cold water is shortcutting.  Fair chance it broke because it corroded off. As such, it's worth looking at the anode, whose one job is to corrode first.  If it's used up, corrosion spreads to other components; good heater design calls for it to be easily replaced components. 

The heating elements can also be swapped, and that is likely to take care of the tripping. You know the tripping is a safety device.  It's like a circuit breaker; when a breaker trips, the breaker isn't bad, the circuit is being overloaded.