A toilet that rocks or shifts when you sit on it needs to be fixed immediately. A loose toilet will eventually break the wax ring seal and leak sewage onto your floor.
Pry off the plastic caps at the base. Use an adjustable wrench to gently tighten the floor bolts — alternate sides and go slowly. Do not overtighten.
If the toilet still rocks after tightening the bolts, slide toilet shims under the base at the points where the toilet lifts off the floor. Work them in gradually until it sits completely stable.
Score and snap off excess shim material with a utility knife. Run a bead of clear silicone caulk around the entire base of the toilet.
If the floor underneath is soft or rotted, or if you see water staining around the base, the wax ring has already failed. That requires pulling the toilet and replacing the wax ring.