Toilets should be securely mounted to the floor.
Tightening the bolts that anchor the toilet to the floor can fix a small amount of side-to-side movement.
The bolts are located on both sides of the toilets base, usually under a plastic cap.
Do not over tighten them, it is very easy to crack the porcelain (toilet).
A back to front rocking motion may require the insertion of shims as well as tightening the bolts.
If a toilet has a definite side-to-side movement when rocked, begin by replacing the wax ring/seal.
If this is not done the toilet will leak, rotting the floor of the bathroom.
The seal between the toilet and the sewer pipe is made with a wax ring, this prevents water leaks when the toilet is flushed and the stops sewer gasses escaping the toilets drain pipe and getting into the home.
To replace the wax ring, the toilet must be completely removed.
The wax ring looks like a 6″ donut made of “sticky stuff” that costs less than $2
NOTE: Most toilets use the standard size wax ring.
There are two different diameter sizes of wax ring, as well as a special thick wax ring that is used if the toilet is raised up to allow for a tiled or hardwood floor.