Researchers at Midwestern University, Duke, Stellenbosch and the Paris natural history museum mapped the appendix across the mammal family tree. They checked diets, social structure, and gut anatomy in 533 species to see whether the organ tracked any single factor.
The appendix turned out to be scattered across distantly related mammal lineages, which meant it must have evolved independently at least 29 times rather than just once in a common ancestor. Diet did not explain it; the appendix tracked the shape of the cecum and the lymphatic tissue in it.
The lymphatic link fits an older idea, drawn from studies in people, that the appendix shelters beneficial gut bacteria through a bout of infection, reseeding the intestine afterward, though no one has caught the organ doing this directly in a living mammal.

Read the original study
Smith et al., Comptes Rendus Palevol, 2017 · doi.org/10.1016/j.crpv.2016.06.001
Evolution kept building the same backup.
Source
- Smith, H. F., Parker, W., Kotzé, S. H., & Laurin, M. (2017). Morphological evolution of the mammalian cecum and cecal appendix. Comptes Rendus Palevol, 16(1), 39–57. https://doi.org/10.1016/j.crpv.2016.06.001