The W-2 income is the 'bargain element', or the discount you received on the FMV stock price when you exercised your stock option.
The 1099-B reports the gain/loss from the sale at cost basis (without the bargain element) to sales price, so both do need to be reported in your return.
The tax consequences have alot to do with the Grant Date/Exercise Date/Sale Date combinations.
Here's an article that explains in detail:
https://turbotax.intuit.com/tax-tips/investments-and-taxes/incentive-stock-options/L4azWgfwy