Short answer. eBike wobble is usually caused by loose headset bearings, out of true wheels, worn tires, or a bent frame. Loose headsets are the most common and the easiest fix. Do not keep riding a wobbling eBike above 15 mph.
Step by step
Test the headset. Squeeze the front brake and rock the bike forward and back. Any clicking or looseness at the head tube means the headset needs adjustment.
Spin each wheel. Lift each wheel and spin it. Watch for side to side wobble. Anything more than 2 mm needs a truing.
Inspect tires for wear. Bald or unevenly worn tires cause instability. Replace before continuing to ride.
Get professional help for a bent frame. Frame damage from crashes or heavy impacts is usually not a home fix and often means the frame is done.