In the Star Trek universe, NCC stands for "Naval Construction Contract." The numbers after represent the contract number. So NCC-1701 is, Naval Construction Contract 1701.
NX stands for "Naval eXperiment." The numbers represent the experiment number, but these experiment numbers are also shared with official contract numbers. Thus, NX-01 is Naval Experiment 01.
When a contract is drafted for a similarly named vessel, an additional letter is used to designate that it is a more advanced ship than the previous one. Hence the designation NCC-1701-D for the TNG era ship.