Hi Vickiecube.
GMAT scoring takes into account both the number of questions you answer correctly and the difficulty of the questions you answer correctly and incorrectly.
So, since the number of verbal questions you answered correctly was the same on both tests, the difficulty of the questions you saw must have been different.
You can likely get some insights regarding why the difficulties were different by considering the patterns of the questions you missed.
I'm guessing that, on the test on which you scored higher on verbal, you got all of the early questions, which tend to be relatively easy, correct and then sporadically missed hard questions throughout the section. In contrast, on the verbal section on which you scored lower, you probably missed some of the easier questions toward the beginning and therefore saw mostly relatively easy questions for the rest of the section.
Meanwhile, the truth is that it's relatively rare for someone to score V40 with 10 missed questions. Normally 10 missed questions results in a lower score. So, you missed just the right questions to get V40 while missing 10, and therefore, the fact that you also scored V31 with 10 missed questions is not as surprising as it appears from your two outcomes.
For some more on the GMAT scores associated with different numbers of correctly and incorrectly answered questions, see this post.
How Many Questions Wrong on the GMAT to Get 700?