On many of this type of solenoid they have an "end of stroke" switch and the solenoid has two coils.
When you first apply power the switch is closed so BOTH coils are used in parallel to operate the solenoid.
Once the solenoid is closed it only takes a small amount of power to hold it on so to save overheating
and using power, the end of stroke switch disconnects the "main" coil and just leaves a holding coil operating.
If your solenoid is cycling the holding coil may be shot so when the end of stroke switch opens there is nothing to hold it closed and it starts to release which re-engages the main operating coils and it oscillates back and forth.
Depending on how it is constructed you need to diagnose the circuit to the "holding" coil if it is accessible. If it is all internal you will need a new contactor.
Oops, tried to add more information, apology if this messed up. The Edit function was not allowing edit.
On your solenoid the end or stroke switch could be removing the short across a resistor so now the resistor is in series with the coil to reduce power but still have enough current
to hold it in. If the resistor is bad, then when the switch opens the current
would drop to zero and cause the cycling like described above.