How did you get into the flywheel area to squirt WD40??? Are you mistaking 'flywheel' for crankshaft pulley, or something else???
That thing on the starter that you are referring to is called a 'solenoid'. WD40 wouldn't hurt it.
The flywheel is bolted to the flange of the crankshaft and islocated inside the bell housing of the transmission. The starter bolts to the engine block or transmission housing (depending on the design) and meshes with the 'ring gear' which runs around the circumference of the flywheel. You can gain access to the flywheel to check the condition of the ring gear teeth, whether the flywheel has loosened from the flange, and you can also check the runout (whether it is warped, etc).
If you have teeth missing on the ring gear, your starter can spin up but the engine wont crank over unless you are lucky enough to have stopped on a good portion of the ring. If your starter has teeth damaged or missing on the drive, same thing.
If the electrics of the starter are fongued, likewise it wont work. That includes, but is not limited to, the condition of the mystical 'solenoid'.