It is widely accepted that there is an inextricable link between neural computations, biological mechanisms, and behavior, but there exists no framework that can simultaneously explain all three. Here, we show that topological data analysis (TDA) provides that necessary bridge. We demonstrate that cognitive processes change the topological description of the shared activity of populations of visual neurons. These topological changes provide uniquely strong constraints on a mechanistic model, explain behavior, and, via a link with network control theory, reveal a tradeoff between improving sensitivity to subtle visual stimulus changes and increasing the chance that the subject will stray off task. These discoveries provide a blueprint for using TDA to uncover the biological and computational mechanisms by which cognition affects behavior in health and disease.