To start with sounds like you have either a issue with a switch or wiring. The CDI unit is powered by the CDI magneto (it has no battery power running to it). So if it is running correctly from pull start and not from electric start then you could have a bad start relay, bad neutral relay, bad wiring, bad switch, Bad connection in a connector or Lose ground wire could also cause this.
If you have a voltage meter hook red lead to positive on battery and hook black lead to B/W wire coming from kill switch. If at any time this shows 12 volts then the ignition circuit is killed. If it shows 12 volts during electric start then that means the kill circuit is grounded. This test will tell you when the kill circuit is not allowing it to fire.`
Look at the neutral light. Does it stay on when you mash the starter Pushbutton? This sends a ground to the CDU unit that has to be grounded for the start circuit to energize, if the neutral light is going out the your losing ground to the CDI. I had this problem and it was a bad relay, contacts in the relay were made all the time allowing the starter to turn over in any gear but it would not fire unless it was in neutral.
The kill switch is bad about being intermittent and the contacts when closed kill the machine (this handle bar switch cause more problems then most of the other wiring put together). Disconnecting this to take that out of the circuit(either cut the b/w lead or use a tool to remove the lead from the plug, you will have to hook this back up after troubleshooting). It should start and run with it disconnected if it is this switch causing the problem. Your start pushbutton and kill switch is in the same assembly on the handle bar, pushing the button could be causing the kill contacts to make and not allowing the machine to fire..
The issue sounds like the cdi is grounding on its kill circuit when the starting circuit is engaged. Most all the wiring diagrams are about the same except for a few things, like reversing relay 1988 has it but most don't, this one is for a 1988 Yamaha Big bear. Highlighted in yellow is the black wire which is ground. Red is the R/W wire witch is comes from brown 12+volt. The green highlighted wire B/W is the kill circuit, if this is grounded at any time, then the machine will not fire.