Roughly, religion is a community's costly and hard-to-fake commitment to a counterfactual and counterintuitive world of supernatural agents who master people's existential anxieties, such as death and deception.
Cultures and religions do not exist apart from the individual minds that constitute them and the environments that constrain them, any more than biological species and varieties exist independently of the individual organisms that compose them and the environments that conform them. They are not well-bounded systems or definite clusters of beliefs, practices, and artifacts, but more or less regular distributions of causally connected thoughts, behaviors, material products, and environmental objects. To naturalistically understand what "cultures" are is to describe and explain the material causes responsible for reliable differences in these distributions.
In the course of life, all such systems (i. e., the different evolutionary ridges) are somewhat functionally interdependent, as are components within each system (i. e., the different programs, schema, modules). Nevertheless, each system and system component has a somewhat distinct evolutionary history and time line. There is no single origin of religion, nor any necessary and sufficient set of functions that religion serves. Rather, there is a family of evolutionary-compatible functions that all societies more or less realize but that no one society need realize in full.