It could be a loose connection, the relay could be overheating and opening up, the on off switch could be at fault or it could have a thermal reset switch to protect the electrical system from over heating and causing a fire.
If it is tripping a thermal switch the unit not going to last much longer.
With two years of use it could be tripping a thermal switch, if it has one, because it is loading up because the second stage piston rings have deteriorated, melted, and are causing a serious load on the motor.