Affinity affects staining by determining the selectivity and intensity with which dyes bind to tissue components. Dyes with high affinity for certain cellular structures will produce a more intense and specific coloration. This is crucial for identifying various cellular structures and understanding tissue morphology. Conversely, low-affinity dyes may result in weak or non-specific staining, making it difficult to distinguish between different tissue elements.