Yeah the learning curve is steep on those things. Bummer, but you sure aren't alone, my first ride went 1/2 mile.
here's what to look for on the next try.
1 if the fork got damaged or bent any this time, forget that fork. You will need a replacement. so look for evidence that the dropouts have spread open.
2 If the forks are ok, then look for any kind of deviation from a big flat surface. some forks have a little bent tab, others have a little cup that fits a quick release. Anything that allows an air space under the big electric hub washers will cause the hub nuts to loosen as the washers slowly deform into the space.
3 Get a washer with a big hole and a small outer diameter, or file away proturberances, or best yet, get a bike or fork that has a big flat steel dropout.
4 Install the hub as follows. Gently torque the nuts to a snug but not very tight fit. Mabye 5-10 ft pounds. Use a fairly short handle wrench, because you can easily strip an axle. Look for any indication that the fit isn't perfect. If the hub wants to squirt out of the dropout as you tighten it, its a HUGE RED FLAG WARNING.
5 Wait 5 minuites, even with a good fit, the washers need a bit of time to slowly begin to deform just a hair and reach a perfect fit. Then tighten a bit more, this time pretty tight, but not with all your strength, especially if you have done a lot of work that gave you a strong arm. Watch for movement, be sure the pressure is not slowly spreading the dropouts. Wait 15 minuites, about the time it takes to wire your controller and tie down the wires. Then do a short no load test, just a few seconds to see if everything is straight and no unforseen problems exist when the wheel is spun.
6 One more time, by now the washers are settled in, and the fork isn't bending. Usually you can get just one more tiny bit tighter on the nuts without stripping an axle with too much torque. At no time is this as tight as you would do a lug nut, but you want all the tightness you can get without putting a big long handle wrench and ripping the threads apart with it. The idea is to use a relatively light hand, but still get all you can with that.
At this point, if no warning signs are seen, you can be pretty confident that the dropouts are good enough, and the motor won't spin with normal loads on it, like 36v full throttle. Check the nuts again after the first ride, sometimes another hair of tightening is possible after the first ride. Installed this way, I have had hubs go 1500 miles with no loosening of the nuts
Good Luck and be carefull, see what is happening instead of merely looking.