When Martha told Mary that Jesus had come, Mary “arose quickly and came to him.”1 Shortly earlier, “many of the Jews came to Martha and Mary to comfort them concerning their brother.” Then the author wrote,
20 Then Martha, when she heard that Jesus comes, met him, but Mary sat in the house.
The author does not actually state that Martha and Mary were both informed together that Jesus was coming. Rather, the narrative seems to suggest that Martha was informed separately (how, the author does not state) and then later Mary was informed by Martha and immediately went to meet Jesus.
So, Mary sat in the house, mourning for Lazarus,2 while Martha went to meet Jesus, since only Martha knew at that very moment that Jesus was coming.
1 John 11:28–29
2 It was the custom to sit while mourning, also known as sitting shiva (i.e., sitting for seven days; cf. Job 2:13).