Washer fills with water then drains:
The critical question is. Is the water is just running down the drain but the pump isn't running. If it is being pumped out, and you can hear the pump running just the same as when it's emptying prior to spin then it could be aborting the wash because it is, or it thinks it's overheating. ( due to defective water temperature switch)
If the pump is failing to shut off then there is something wrong with the electronics. If your washer is a mechanical timer controlled device then you may have a sticking switch (which may explain if switching cycles does something for you). But if you have an electronic timer then you may be experiencing a board failure, where a cycle is being commanded when it is not intended to by design.
If water isn't being pumped out, but just draining away all the time, the washer will keep detecting there isn't enough water inside and top up with more.
Modern washing machines should be sophisticated enough to realize something's wrong and abort with an error, but if not, it may continue washing or rinsing for a short while before losing enough water to trigger more coming in again. It can get stuck on this cycle indefinitely and it's called siphoning.
Siphoning occurs when the end of the drain hose is lower than the level of the water inside the washing machine.
Try raising the hose and see what happens.
Also the drain hose should have some type of air gap where it fits into the stand pipe. It should not have an air tight fit.
Either it's siphoning down the drain due to an issue with the plumbing, it's overfilling, or also if it ( THE WATER) overheats then in some machines the software will employ a fill and drain tactic to cool down the water. The important thing is to work out which of these different faults is causing the problem by careful observation.
Other switch's to check would be the water inlet valve and the water pressure switch with a multi meter for continuity or OHMS.
And in some modern washers that come with THERMISTORS
One symptom of a washing machine that thinks it's overheating and thus fills and drains at same time ( possibly because of a faulty thermistor
) is if it's filling with cold water and pumping out at the same time. This is covered in this articleWashing machine fills and drains at same time
although the same symptom can be caused by other faults.
On some models that have belt drive the WIGWAG selenoid could be defective or the spin and agitate bars could be bent or worn, or the spring worn or broken.
By the way my advice is free cuz God is good!