There are three different ways 3D printers work but they all rely on the printer converting a design into individual 2D slices which are then combined to make the final 3D object.
The first method uses a pool of chemicals that turns solid when light, typically a UV laser, is shone on to it. The laser moves across a thin layer of liquid, drawing the required design. Once the first layer is finished the resulting solid is lowered to allow a second thin layer of liquid to be deposited on its surface. The laser is then used to outline and solidify the design.
A second method uses ink that becomes solid when it emerges from the printer head. Designs are drawn out by the ink and again built up layer by layer until the final product is complete. A final method uses layers of powdered material, held together with glue or heated to fuse the powder together.