The fuel solenoid is designed to turn off fuel supply anytime the key is turned off. The
for your tractor model might have an electrical schematic in it that can help you determine the wiring involved.
Essentially the solenoid grounds to the carburetor and when the key is turned on power is sent to it via a wire, typically blue in color, and the solenoid opens. Normally you can hear the solenoid engaging with a "click" when you turn on the key. Or, if you put your hand on it you can feel the solenoid react.
To confirm the solenoid is the problem, first find the wire going to it and test that it is receiving voltage from there as it should. If not then you have some other issue going on.
If there is power getting right to the solenoid and you cannot hear or feel it reacting that is likely the problem but you can test it for sure. Take it out of the carburetor and set it on a good clean metal part of the engine so it is grounded. Then jump power from a live on the tractor to where the wire normally connects to the solenoid. The solenoid should move, though the distance it moves is not large. Be sure to watch your hands as the solenoid may engage rapidly and you do not want to get pinched or shocked.
The fuel solenoids are typically pretty reliable and most times the problem is elsewhere, so if it is not clear that the solenoid is at fault you might consider consulting a professional to be sure some other wiring or carburetor issue is not going on.
Or, feel free to submit another question here and include the actual tractor model number as noted on the decal on the fender, usually just behind or under the seat, and we will do our best to help further.