Galaxies represent the main form of organization of matter in our universe. Therefore, they are of obvious interest for the new multidisciplinary field of astrobiology. In particular, to study habitability of galaxies represents one of the main emerging challenges of theoretical and numerical astrobiology. Its theoretical underpinnings are, however, often confused and vague. Here we present a systematic attempt to list and categorize major causal factors playing a role in emergent habitability of galaxies. Furthermore, we argue that the methodology of cosmological merger trees is particularly useful in delineating what are systematic and lawful astrobiological properties of galaxies at present epoch vs. those which are product of historical contingency and, in particular, interaction with wider extragalactic environment. Employing merger trees extracted from cosmological N-body simulations as a new and promising research method for astrobiology has been pioneered by Stanway et al. (2018). We analyse the general issue of applicability of merger trees and present preliminary results on a set of trees extracted from the Illustris Project. In a sense, this approach is directly complementary to using large-scale cosmological simulations to study habitable zones of individual galaxies with high mass/spatial resolution; taken together they usher a new era of synergy and synthesis between cosmology and astrobiology.