Chemical stains work by binding to specific molecules or structures within a sample. When applied, the stain selectively attaches to certain elements, making them stand out against the unstained parts. This selective binding is crucial for studying the intricate details of nanomaterials, such as carbon nanotubes or quantum dots.