Each pixel of a digital camera can store only the light levels, so essentially a sensor is monochrome. To get colour information each pixel has a mask of one colour. Bayer pattern used in most cameras has a Green, a Blue and two Red masks in a cluster of four touching pixels. So even though the sensor has say 20 Mega Pixels, 10MP are Red, 5MP are green and 5MP are blue. RAW format stores the image data as seen by the sensor, along with a host of other supporting data. Why BAyer pattern and not RBG, is because Bayer uses only one pixel while RBG needs 3 pixels - essentially the Bayer pattern needs 1/3 the pixels. The down side is that the colours are not exactly true but interpolated for each pixel.
JPEG on other hand has colour information for all the 20MP pixels, in effect it has data for 20MP Red, 20MP Blue and 20MP Green - thrice the data that the sensor had collected! In camera JPEG is RAW processed by the camera.
The conversion of 20MP Bayer pattern to 20x3MP of RBG is called demosaicing.
NEF file is in RAW format. That format has one entry for each pixel effectively what the sensor sees. To get RBG information you have to use a demosaicing algorithm to create colour information for each pixel. In effect
. Two pixels had Red mask so essentially these had only Red information. After demosaicing they each have R,B,G data.
. One pixel had Green data. After demosaicing it has R,B,G data.
. One pixel had Blue data. After demosaicing it has R,B,G data.
So essentially Demosaicing algorithm is "Guessing" what colour goes to which pixels. Each software has its own proprietary demosaicing algorithm, so the result of one may be more pleasing to the eye than the other.