You should always make sure that the washing machine is completely level and on a solid floor so that the washer or it’s internal parts can be damaged. If the washer is not level it can vibrate excessively especially during the spin cycle.
Washing machines have adjustable front leveling legs with a locking nut. Adjust the front legs to the proper height and then tighten the locking nut so it is up touching the body of the washing machine, this way the leg can not rotate.
Some washing machines have adjustable rear leveling legs that can be adjusted the same way. It’s best to keep the washer as close to the floor as possible.
However, most washers have self-adjusting rear leveling legs that can be set by tilting the washer forward on its front legs and then setting the machine back down. The rear legs should adjust automatically.
If your washing machine is on a slick floor and it keeps sliding then you can put leveling legs pads on the bottom of the legs to prevent it from moving.