The test is not scored based upon percentage correct - roughly the same # of questions wrong can result in almost any score.
Most likely, on the test on which you scored a 31, you were answering somewhat easier* questions incorrectly - easier compared to some of the questions that you were answering on the 37 test. This would have resulted in you getting an easier mix of questions overall, so you still answer about the same number of questions incorrectly but your score is lower.
Alternatively, you might have had a scoring drop towards the end of the section. The test uses a "where you end is what you get" principle, so if you were running out of time, or mentally fatigued, or for whatever reason had a string of wrong answers bring your score down at the end, then... where you end is what you get.
So go take a look at those results. Did you have a drop in performance towards the end? Did you have any instances of a long string of wrong answers (4+) or a longer sequence in which most of the questions were wrong (eg, 6 wrong out of 8)? That can cause pretty significant score drops.
Did you feel more mentally fatigued on that second test? Mental fatigue often feels like this:
http://www.manhattangmat.com/blog/index ... you-crazy/Let's try to figure out what happened so we can tell what you need to do to make sure that you can get a better score on the real test.
I recommend reading this:
https://www.manhattangmat.com/blog/inde ... lly-tests/And you might want to look through the Scoring section of our free e-book The GMAT Uncovered, just so that you understand better how the scoring works.