I guess it can seems odd to you because you didn't see it coming and you wonder what could be "the cause". Thing is, there isn't "a reason" that makes someone be transgender. Some people are just trans, that's all.
Since I don't know your child's gender and pronoun, I'll use "them" and won't assume they're either a girl, a boy or a non-binary person.
Maybe the loss of their grandfather made your child realize that they would have liked their grandpa to know them as who they really are (and not as they were assigned at birth).. and then it could have been a trigger point to decide to come-out to the family. Or maybe it was already planned and well, your father died just before... that happens..
The important thing to have in mind is that no, nothing makes people "become" trans, so your child is what they say they are.
Having bought a dress just a year before doesn't mean anything : lots of trans people try for a long time to fit in the roles assigned to them by society... Maybe they really tried for a long time to be what they were told to be, because they didn't know that it was possible to be of a different gender that the one assigned at birth. You know, when all your life people tell you for instance "you're a girl", but not only people : school, science, movies etc, everything tells you you're "a girl" well, it's difficult to think and accept that it can be wrong, and that you can, in fact, be of an other gender... and that it's ok...
So well, if your child has been assigned girl at birth and bought a dress before, they may have done that only to try to fit in, or to convince themselves (there is so much stigma on trans people, it's not always easy to accept that it can concern us).. or just maybe because they like(d) dress : some guys do, and that's ok too ^^
If your child has been assigned boy at birth and bought a dress before your father's death, then well, it's a sign that they knew they were trans before and tried to express their gender as they wanted to.
So the point here I guess is : trust your child. And support them :) That's clearly the best you can do. And if, for any reason, they were to change their mind and realize it's not in fact who they are, then it's a part of their self-discovery journey, and that's ok too. People can think and feel something one day and realize after that in fact it's not quite what's right for them.
It's reaaaally rare though for trans people, but if it happens, it's not a big deal. All your child needs is your love and support :)
Just one last thing : if your child is a transgender boy, the first thing you could do as a way of supporting them, would be to use the pronouns they're using for themselves. Chances are that as a boy the correct pronouns would be "he/him/his". :) You'll see, it's just a change of habits, and the human brain is very good to change habits, with will and practice :)