Start with the load
Heavy items like towels, jeans or a single bedspread can bunch up on one side of the drum. That throws the drum off balance and makes the whole machine thump.
Stop the cycle, spread the clothes out evenly and add a few lighter items if needed. Then restart the spin.
Check that the washer is level
Push down on each corner of the top. If the machine rocks, one of the feet is off the floor.
Most washers have adjustable feet. Turn them until the machine sits firm and does not wobble, and tighten any lock nuts. Pull it out only as far as you safely can, and be careful with the hoses and cord.
When the cause is worn parts
Inside, shock absorbers or suspension parts hold the drum steady while it spins. Over time they wear out, and the drum starts to bang against the cabinet.
If the load is even and the feet are level but the noise continues, worn parts are likely. Those cannot be fixed by adjusting something. They have to be identified, ordered to fit your model and installed.
Running a washer that bangs hard can damage other parts, so it is best not to keep using it.