3D data storage works by stacking multiple layers of data vertically. This is achieved through the utilization of nanostructures that can store information at a molecular or atomic level. Techniques such as nanoimprinting and self-assembly are employed to create these intricate patterns. Each layer can be independently accessed, allowing for high-density storage and efficient retrieval of information.