Why do electromagnetic waves move in an oscillatory motion when they come across an electron?
Well, not only across an electron, but everywhere.
The basic characteristic of electromagnetic waves is that there are, well, waves. This means that at every point in space, the strength (amplitude) of the electric and magnetic fields oscillates - very similar to waves in the ocean. Note, though, that the waves don't have to move in order to oscillate, as the strength of the field is measured at a single point (they do move, though, at the speed of light).
One key difference between electromagnetic waves and waves in the ocean, is that electromagnetic waves do not require a medium to be in, in order to exist. Rather, they can exist anywhere, including in vacuum. They would oscillate everywhere - if there is an electron nearby, and if there isn't.
One way to understand this is that in order to produce an electromagnetic wave, electrons must be moving in a periodic motion- this is exactly what happens inside an antenna that produces radio signal: electrons move back and forth in an oscillatory way, thereby they accelerate. This acceleration is what causes them to emit the electromagnetic radiation (waves) which oscillate as well.