Sounds like a wiring problem or a shorted solenoid inside the trans. The wiring runs down the back of the engine over the top of the trans and it could have come loose from the harness retainers, at which point it may have melted on the exhaust. I would inspect the wiring first.
Then you can ohm out the solenoids. You will have to obtain a diagram of the trans circuitry so you can check the solenoids.
Being that the The problem sounds intermittent, ohming the solenoids may or may not prove anything. Intermittent troubles like yours makes me lean towards a wiring problem anyhow. Look around for bare or melted wiring .
Might also be a good Idea to check the plug at the trans, unplug it and inspect it. Maybe it is full of water/corrosion
Fact is stranger than Fiction