One of these issues is the MTP (Media Transfer Protocol) connection option. It lets you copy any file back and forth between your phone and computer, but is not set as default on Marshmallow. Thus, when you plug an Android 6.0-laden handset in the USB port of your computer, it will start charging, as that Charge mode is the one set as default.
1. Download and install the MTP enabler file on your phone;
2. On first run, the app will ask you to choose between a manual MTP switch ("Ask me for action" option) and an automatic one;
3. If you want MTP to be the default connection mode and be chosen automatically, leave the "Ask me for action" option upon initial setup unchecked. The phone will then try and initialize an MTP connection each time you plug it into a USB port;
4. Alternatively, you can place the app's small widget on your homescreen, and tap it once before you connect your phone to go into MTP mode.
source: tomas1pit (XDA-Devs)