This is done using an optical process, not unlike how old photos were printed. A silicon wafer is covered with some etching resisting material, and then exposed to UV light through a mask. The mask is a drawing of the chip schematic.
The etching resisting material is removed where the light hits (or vice versa), and parts of the silicon wafer is etched away with a chemical. Different layers can be deposited by repeating this process.
Finally the wafer is cut into little rectangles and placed inside a housing.