Quick answer
Find where the movement is. If the pedal moves against the crank, tighten the pedal to its torque first. If the movement is inside the pedal, along the axle, the bearings need adjusting or replacing. A crank arm that wobbles is a separate problem.
Find where the play is
Hold the crank steady and grip the pedal body. Push it side to side and up and down. Work out whether the movement comes from the joint between the pedal and crank, or from inside the pedal itself, at the axle or bearings. Some play is normal in worn pedals, but clear movement or a knock should be fixed.
Snug the pedal first
If the pedal is loose in the crank, it can move side to side. Remove it, clean both threads, grease them if the maker recommends it, and refit to the torque in the maker’s guidance. Recheck after a few rides, since the pedal can settle.
Adjust the bearings
If the pedal is tight in the crank but still moves inside itself, the bearings need attention. On cup-and-cone pedals, adjust the cone to remove the play while keeping the axle turning smoothly. The steps are in the guide to servicing pedal bearings.
Worn bearings or axle
If you cannot remove the play without the pedal binding, the bearings or axle may be worn. Replace the bearings if the pedal allows it, or replace the pedal. Look for a rough feel, pitting or a bent axle. A bent axle means the pedal should be replaced.
Play is not crank wobble
A pedal that moves on its axle is one problem. A crank arm that wobbles side to side is another, and its fix is in the crank’s fitting and bearings. If the crank arm moves and the pedal itself is tight, look at the crank rather than the pedal.