The story you described matches “The Long Years” a story featured in <PERSON> The Martian Chronicles.
<PERSON> said, “I went to the graveyard.” -“The four crosses were there?” (<PERSON>) -“ The four crosses were there, sir. The names were still on them. I wrote them down to be sure.” He read from a white paper: “<PERSON>, <PERSON>, <PERSON>, and <PERSON>. Died of unknown virus. July 2007.
<PERSON> drank down his wine. He did not cry as he fell forward onto the table and slipped to the ground... “Say good-by to <PERSON> and the children for me.” (<PERSON>) -“Just a moment, I’ll call them”. (<PERSON>) -“No, no, don’t!” gasped <PERSON>. “They wouldn’t understand. 417
I wouldn’t want them to understand!”
Some quick research reveals that there is indeed a film adaptation of this story, Episode 3 of “The Martian Chronicles miniseries”: The Martians. see https://www.imdb.com/title/tt1266007/?ref_=tt_eps_rhs_0
More successful is the adaptation of “The Long Years”, which sees <PERSON> (“Space: 1999”) as a lonely tinkerer named <PERSON> who uses lasers from his home observatory on Mars to signal passing spacecraft. <PERSON> succeeds in gaining the attention of <PERSON> (who was in the short story as well), along with <PERSON> Father <PERSON> (who was not). <PERSON> has been living with his wife <PERSON> (<PERSON>) and 14 year old daughter <PERSON> (<PERSON>), who was named after <PERSON> own beloved wife. <PERSON> and Father <PERSON> greet <PERSON>, who is tremendously excited to see another human being…not quite the reaction one would expect from a man who already has a family for companionship. <PERSON>’s excitement turns lethal, as he suffers a heart attack before collapsing dead to the floor of his home. <PERSON> and <PERSON> stare blankly at his corpse, unable to cry, since they are androids, built by <PERSON> after the real <PERSON> and <PERSON> passed away, some years earlier. The truth of <PERSON>’s existence deeply saddens <PERSON>. He and Father <PERSON> decide to leave the two androids ‘on’ in their preprogrammed blissful state, after burying <PERSON> near his real family. A coda to the story sees a still-wandering <PERSON> walking up to the <PERSON> home, introducing himself to the two smiling androids…
synopsis from https://musingsofamiddleagedgeek.blog/2020/05/18/revisiting-the-martian-chronicles-tv-miniseries/ 715