The novel often alludes to the nursery rhyme "Mistress Mary Quite Contrary," using it to underscore the changes in character that Mary Lennox undergoes. These allusions create a running motif that functions as a shorthand for whenever the narrator wants to indicate that Mary is misbehaving. This first comes up in Chapter 2, when one of the Crawford children becomes annoyed with Mary's bad attitude and starts to tease her. It unfortunately sticks so much that even their parents take it up:
“She is such a plain child,” Mrs. Crawford said pityingly, afterward. “And her mother was such a pretty creature. She had a very pretty manner, too, and Mary has the most unattractive ways I ever saw in a child. The children call her ‘Mistress Mary Quite Contrary,’ and though it’s naughty of them, one can’t help understanding it.”
Mrs. Crawford equates Mary's behavior to her physical appearance in this segment. She is a "plain child," while her mother was a "pretty creature," and so it stands to reason—given the logic of the novel—that Mary would have "unattractive ways." The rhyme itself goes as follows:
Mistress Mary, quite contrary
How does your garden grow?
With silver bells, and cockle shells,
And marigolds all in a row.
"Contrary" in this context means "disagreeable," and Mary Lennox is "the most disagreeable child" anyone has ever met. The phrase "Mistress Mary" becomes a reference to her intractability wherever it occurs in the book. When the narrator calls this character "Mistress Mary," as they often do, it is an indicator for the reader that Mary is behaving in a particularly unpleasant, spoiled or high-handed way.
When the phrase occurs later in the book, it functions as a reminder for the reader of how Mary used to behave and approach things. By that point, it has become shorthand for the previously spoiled and bad-tempered version of the little girl. When the narrator calls her "Mistress Mary" in the second half of the novel, it feels like a fond joke rather than a criticism.
The nursery rhyme would have been well-known to any British child of the era, and would have added the connotation of gardening to any reference to the protagonist whenever it came up. Because it first occurs so early in the novel, and is actually the title of the second chapter, it indicates to the reader that Mary's storyline will have something to do with both contrariness and gardening.
In Chapter 2, Burnett makes an allusion to the French fairy-tale "Riquet à la Houppe." Mary recalls this tale as Medlock tells her the story of the tragic and sudden death of Mrs. Craven, and the despair into which it threw Colin's father:
“She was a sweet, pretty thing and he’d have walked the world over to get her a blade o’ grass she wanted. Nobody thought she’d marry him, but she did [...] “When she died—” Mary gave a little involuntary jump. “Oh! did she die!” she exclaimed, quite without meaning to. She had just remembered a French fairy story she had once read called “Riquet à la Houppe.” It had been about a poor hunchback and a beautiful princess and it had made her suddenly sorry for Mr. Archibald Craven. “Yes, she died,” Mrs. Medlock answered. “And it made him queerer than ever."
Riquet à la Houppe is a French fairy-tale from the 1600s that echoes one of the major themes of The Secret Garden; that physical wholeness and beauty are immaterial without a good character to support them. This allusion also has the secondary effect of linking the wild and rugged world around Mary in Yorkshire to another fairy-tale setting. Archibald Craven is often described as having a "hunchback" in this novel, and this unkind term for a person with kyphosis is what reminds Mary of this story.
Relating the main character of this tale to Archibald Craven helps Mary to contextualize the tragedy that has occurred at Misselthwaite. Through the use of this analogy, Burnett demonstrates two things at this early stage. Firstly, that Mary can feel sympathy, and secondly, that she is only able to do so through the lens of stories she has already been told.