I'd pull the starter and hook it up direct to a battery and see what happens.
If the gear pops out when you power it, and retracts when power is removed, then your starter is probably not the problem.
I serously doubt your switch would have anything to do with the selonoid engaging or disengaging the gear from the flywheel.