You have several potential root causes for these issues.
1) The keyswitch is one suspect for sure. It is the common denominator between start and run circuits.
2) The neutral safety switch, either incorrectly adjusted or faulty will affect start circuit only.
3) Faulty starter solenoid, even though you may hear it "clicking" will affect start circuit only.
4) Corrosion or broken wiring in the wiring harness, usually at the keyswitch connections or where the harness exits the engine and has been subject to normal bending and kinking from turning and tilting.
If you have a panel mounted keyswitch on your dash that is subject to getting water in the switch from rain or washing the boat, this can cause the random starting or running issue, this is more common than you think. Sometimes you'll actually hear the water sizzling in the keyswitch after the engine shuts off.
The quick and easy way to isolate the keyswitch and wiring as a problem is start the engine at the ramp. Disconnect the big red plug under the cowl and go out and run it, it won't hurt anything and if the engine runs fine for an extended period, it's not an engine problem. Of course you will have to reconnect the red plug to be able to shut the engine off when you're done with this test. Your engine generates its own electrical voltage to run so it only needs the battery to turn over the engine.
One thing to also consider, your engine must turn a minimum of 300 rpm cranking speed in order to light up the ignition system and have the engine fire up and run. A weak battery, bad starter, dirty corroded battery cables or connections or solenoid can cause low cranking speed and engine will not fire. Quick story; years ago we had a 115 Johnson in the shop for a similar issue. The engine had no fire when you cranked it with the starter so the first thing we thought was something bad in the ignition system but all the static engine tests came back OK, including checking the spark with the plugs out. (The engine turned over faster without compression so it had fire, put the plugs back in, no fire!) This engine did not appear to be cranking too slowly. Sure enough, if you pulled the engine over with a rope around the flywheel it would light up every time. With the starter, no fire. This made no sense since the engine did not need 12volts to run so even a high amperage starter draw would not take away from battery voltage to fire up the ignition like older battery ignition systems. We put a new battery in it, same thing! Somebody finally said, F#*^% it, put a new starter on it. Engine fired right up every time! So even though this starter appeared to turning the engine over fast enough, it was not! So after 5 hours of screwing with this engine, Lesson learned! That was 25 years ago and never forgot that one.