For a more specific answer post the following information: Make/Model/Year/Engine Model/Deck Size, and hours on meter if you have one. A short description of the events preceding the beginning of the problem is also helpful.
The following generic information applies to just about every riding mower out there.
When you turn your key many things happen. One of those happens only when you turn all the way to start. In this position current, from the battery, travels down a small wire to your "starting solenoid". You can find this solenoid by following the very large wire backwards from your starter motor on the side of the engine. This very large wire carries a lot of current from the solenoid. Follow the wire down and you will come to a small, somewhat cylindrical device. It's about the size of a large pill bottle; maybe a big bottle of aspirin.
This little device has a magnetically operated plunger inside. When you turn your key the current running down a small wire comes to this solenoid. As it passes through the solenoid it activates the electro-magnet inside. That magnet pushes two thick contacts together. Those contacts bridge the gap between the two large threaded posts that you see on the end of the solenoid.
One of the two large posts has a heavy, thick, wire coming from the battery. The other post has the wire that goes to the starter. While the (internal) contactor bridges the gap between these posts, lots of electrical current flows through the big wires. This causes the starter to turn.
When you release the key from the start position, back to the run position, the internal contactor is pushed away from the posts by a spring. That causes the starter motor to cease turning. It sounds like the spring is broke or the contacts are mildly welding themselves together. In other words the internal contactor is stuck in the "on" position and this keeps supplying current to the starter.
The first problem, broken spring, is the easiest to fix. Just replace the solenoid. There are no internal serviceable parts.
The second problem "internal welding". That might also be fixed by replacing the solenoid. However there is a chance that this is being caused by the starter drawing too many amps or too much current (that's basically the same thing). You will need to test the amperes being drawn by the starter with a clamp style amp-meter. You might have to replace or service the starter. If the starter is drawing too many amps, a new solenoid will likely solve the problem for a while, but then it too will start to weld. Additionally, a bad starter pulling too many amps will damage the battery in a short period of time. You may have to replace both the solenoid and the starter.
One test you should perform is a voltage measurement of the battery while the starter is cranking. Switch a volt meter to DC Volts and clip it across the battery. It should read between 12-13 volts. Leaving the meter connected to the battery, crank the engine. If battery voltage drops below 9 volts when cranking, or while the engine is running, the fuel solenoid will not function. That means the engine will not start or will die soon after starting. So check your battery voltage before, during, and after cranking. If the battery voltage is good (12.4 or greater volts) before, but drops near or below 9 volts while cranking, this is generally a sign the battery has one or more bad cells. Replace the battery. If the battery is in fact good and the voltage is still dropping you may have a bad starter motor which is drawing too much amperage.
Note: many systems have a fuel shut off solenoid. This is a small black cylinder on the bottom of the carburetor. It has two wires running to it. It should make an audible click when you turn the key on.
Another possibility is the Key Switch. The Key Switch may have broken up inside and the multiple terminals which provide current to multiple devices on the tractor have become misaligned. This could cause both of the symptoms you described. The engine won't start AND the starter won't quit. If the terminals are faulty other parts of the system may not be engaging and the engine will not have the proper electrical connections for running. Additionally, the starter solenoid may still be getting current while the key is in the run position.
TEST KEY SWITCH
Put meter in the DC volt position. Disconnect the small wire from the solenoid. Connect one meter lead (red) to this wire and connect the other meter lead (black) to the negative post on the battery. You should see the following:
- Key off - No volts
- Key in Run position - No volts
- Turn and hold key in start position - you should read 12+ volts
- Release key back to run position - it should go back to No volts.
If your readings are like this the Key switch is good. If there is voltage present in the Run position, your key switch is bad. Replacing it will fix the problem.