Contrary to a 2D printer which only prints text or images on a piece of paper, 3D printers are filled with other substances than ink which make it possible to print different layers of filling on top of each other, with a plastic substance for example. In order to move in 3 directions a 3D printer has some extra motors that enable it to move up and down and from left to right.
The motion of the printer head and the amount and kind of filling it releases are all controlled by the 3D model you have on your computer. If you print a coffee cup your printer will know to start at the bottom by printing the base of the cup and slowly move upwards, layer for layer. And when it reaches the bottom of the earpiece of the cup it will know to release extra plastic to eventually create the earpiece.
3D printers could in theory be used to print every item you can imagine as long as you have the 3D model and the right fillings.