To me it's a bit like if a friend was having surgery and required a blood transfusion, I could go to my local blood donation center and donate. Even if my blood wasn't actually used for my friend, when my friend and his family know that I donated blood, they'll consider it as if I had donated directly to my friend.
For cases when someone desires a more direct way to donate to specific funeral expenses, often the family can put you in contact directly with the funeral home, or you could pay for something like flowers, or make a contribution to a foundation the family is directing funds towards.