Once a person is dead, the body looses it ability to fight bacteria and starts to decompose. The people who attend the funeral are exposed to the dead body and hence the bacteria that participate in the decomposition of a dead body. That is the reason why they are asked to bathe immediately after the funeral, before touching anything or anyone.
Head baths after deaths, funerals will make sure that one cleaned themselves from head to toe, and rid of all viruses, bacteria, unhygienic material that may have carried.