There are two Marys in the story. First of all, there's Mary Strorm, David's sister. She's a kind, considerate girl who always looks out for David and Petra, protecting them from their father's beatings. Just as crucially, she urges David not to share his dreams about the city in case he gets into serious trouble. David's insights into the past, as well as his telepathic powers, are considered dangerous in this post-apocalyptic society, and so Mary knows just how imperative it is that David doesn't reveal his special powers to anyone.
The other Mary in the story is Mary Wender, Sophie's mother. Mrs. Wender cares deeply for her daughter, and she is greatly concerned at what could happen to Sophie, given that Sophie is considered a mutant in this heartless, superstitious society. That explains why Mrs. Wender is initially wary of David's involvement with Sophie. She knows just what kind of a religious fanatic David's father is and how he wouldn't hesitate to have Sophie banished to the Fringes.
David is a thoroughly kind and decent young boy at any rate, but his telepathic gift allows him to read Mrs. Wender's emotions before she's had a chance to express them. This enables him to reassure her of the genuineness of his regard for Sophie's welfare.