It's not a tradition, they are just taking the advantage of the funeral scenario, because they can't be arrested by their illegal gambling activity as respect to the grieving family.
Maybe it is an escape for some people, but for the majority of gamblers, I believe it was just for pastime until it became an addiction. Others do play gambling to become the black sheep of the family, to gain attention from their families. We have our own reasons why we play gambling, but I would call it as an "escape".
There is no such tradition and probably almost all funerals are not ideal places to gamble and they just use the funeral as a place to gamble which may be safer. Every gambler must have references regarding involvement in it and almost all who are addicted consider this normal. So before all that happens, we must have control so as not to get involved in it irresponsibly.
Regarding gambling at funerals, maybe only some people take advantage of the place and for me it is quite terrible because they should have looked for a much better place to gamble.