Several inches of mineral sediment on the tank bottom takes up volume that used to hold hot water, and it insulates the burner from the water above it. A fifty gallon tank can effectively become a thirty gallon tank. Flushing recovers most of that capacity.
The dip tube carries incoming cold water to the bottom of the tank. When it cracks or breaks off near the top, cold water mixes straight into the hot outlet. The symptom is distinctive: hot water that starts fine and turns lukewarm quickly, then recovers oddly fast.
Electric heaters have two elements. If the lower one fails, only the top third of the tank heats. You get a short burst of genuinely hot water, then cold. Replacing the element restores full capacity and is a modest repair.
Not everything is a failure. A thermostat set to 110 degrees gives you less usable hot water because less cold mixing is needed at the tap. Around 120 degrees is the usual balance between capacity and scald safety.
A failed shower or tub mixing valve can let cold water push back into the hot line, feeding cold into the whole hot system. Shut the cold inlet at the water heater and open a hot tap. If water keeps flowing, you have a crossover, and the faulty valve needs finding.
If nothing is broken and the household has grown, the tank may just be undersized. Two people on a forty gallon tank is comfortable. Four people with back-to-back showers is not. The choice then is a larger tank or a tankless unit, and the running costs differ enough to be worth comparing properly.
A real plumber, a flat-rate quote, any hour of the day.