Religion latched onto which ever means of disposing of their dead the locals already performed. No different than how religion took over local customs and traditions to help bring in more people into their fold.
Communities that didn't properly dispose of their dead would of experience a net-positive when pushed to follow a religious which their funeral tradition helps prevent epidemics. Those people would most likely of uplifted the religion when they though divine intervention reduced their epidemics. In reality, it was as laws of physics reducing the propagation of contagions.
Fun fact, disposal via vulture consumption is another good means to contain contagions. Their digestive system is like battery acid and kills mostly everything. Natures evolutionary animal that assists with preventing epidemics. A natural wake.