There are only a couple of things that will cause an electric hot water heater to raise its water temperature by itself. The first is a bad thermostat. A thermostat is designed to shut the temperature of the water off when it reaches the chosen temperature, but if the heat-sensing device goes bad, then the water temperature will continue to climb until the backup thermostat shuts off the power. Both thermostats need to be tested to see which one has failed. You will probably need a professional to pull it out and replace it. Unless you are very handy and know electrical safety, it is not recommended that you touch it. Electric water heaters typically have 240 volts going to the thermostat.
The other problem that could happen with an electric water heater is the tube surrounding the element, which separates the element from the water, may be damaged and the element may be heating the water directly. Generally you get hot water for a short period of time, then the element burns out. Sometimes you don't notice that it's gone because the other element continues to heat water. Every electric water heater has two elements, an upper element and a lower element. Both cycle to heat the water. An element is tested with an ohm meter; a small current is passed through the element to see if it is unbroken. If you get a reading from both poles of the element and it is within tolerance, then the element is still good. You have to test it with the power leads disconnected. Again, do not attempt this unless you know all of the safety procedures for 220 volts of power.
If the water heater is more than 10 years old, it is time to consider installing a new water heater. The time factor and parts for rebuilding the old water heater is the same as replacing it with a new one. You may be able to conserve more heat by installing a more energy-efficient model. Enough power may be conserved to eventually pay for the water heater. In addition, you may be able to easily convert to a tankless water heater that stores no hot water and is therefore even more energy efficient.