When I looked my photos in my computer, two images appeared. One is a JPG image and another one is a NEF image. I'd already formatted my memory card but there's no change at all. What should I do? The another file is eating spaces on the memory card.
This is a setting and a feature of your camera. NEF files are what is known as RAW files. They store the actual image data as it was captured by the sensor, before any post-processing is applied in camera. It stores much more information that allows for a lot of valuable post production changes, like altering exposure (to a limited extent) or recovering highlights or shadows. It also allows for improved white balancing and more precise noise reduction, in addition to a number of other advantages.
JPEG images on the other hand, are a simple image format that stores the result of post-processing work that is done by your camera immediately after taking the photo. It does not contain the raw sensor data and offers far fewer options to work with it in post, but is also more ready to be used for other purposes or by general software than a RAW image.
You currently have your camera set to save RAW+JPEG. If you change the quality settings to be either RAW or JPEG, then only one file will be produced for each image captured. If you want the highest possible quality and expect to do post production on the images, then you should shoot RAW only and adjust your images after shooting to produce final images. If you want to simply be able to post or print images as they come off your camera and do not want to do any post production work, then it should be safe to simply use JPEGs without RAW, or if you want the best of both worlds (at the cost of some additional space consumption), you can leave it as it is currently set, which is why the option is available.
It sounds like you are saving your photos as both NEF and JPEG files. You can use the camera's menu to choose to save your files either as NEF only or JPEG only. If you are having trouble formating your memory card with the computer, try formating the card with the camera instead. That is always the best practice. If your camera uses SD cards for storage, you will need to be sure the write protection notch is set to allow writing to the card. If it is set to read only you will not be able to format the card.
The NEF files will be larger because they contain more information from the sensor. This allows you to make more extensive changes to things like brightness,contrast, white balance, etc. in post processing. The JPEG files will be smaller because the in-camera processing decides what part of the information from the sensor to keep and what part to discard. You can make some adjustments on your computer in post processing, but they are much more limited because the information discarded in-camera can not be recovered from the JPEG files.
Compared to the cost of cameras and lenses, memory cards and hard drives are fairly cheap. You might also consider increasing the storage capacity of your card.