Max's comment answers your question: The definition of the $p$-value is the probability that you get a value at least as extreme, and this includes all outcomes more lopsided than the one you observed. It's your choice whether to consider $10-40$ more lopsided than $31-19$, whether to use a two-tailed test or one-tailed, but you must include $40-10$.
If you forget to include the more lopsided terms, then you will compute a small probability and automatically reject the null hypothesis when you use a large number of trials. If you play $1$ million games between equal opponents, the most likely outcome is an even split, and the probability of that is still quite small. ${1,000,000 \choose 500,000}/2^{1,000,000} \approx 1/(500\sqrt{2\pi}) \approx 0.000798 \lt 0.1\%.$ Every score has less than a $0.1\%$ chance to occur! So, if you don't add more extreme outcomes, you would simply confirm that some unlikely event had occurred just because there are a lot of possibilities when you have $1,000,000$ games. If you observe a score of $500,300-499,700$, the actual chance to see a score at least as lopsided in favor of $A$ when $A$ and $B$ are equal is $27.46\%$, and the probability of a score at least as lopsided in favor of either player is twice that, over $50\%$.
It is reasonable to ask why the $p$-value is defined this way. Whuber hinted that the Neyman-Pearson lemma is relevant. Another way to think about it is that we only want to have a chance $\alpha$ to reject the null hypothesis if the null hypothesis is true. If we have a linear ordering on how extreme outcomes are, and we define the $p$-value to be the probability of getting an outcome at least as extreme, then the event that we get an outcome with $p$-value lower than $\alpha$ has probability smaller than $\alpha$.
In different statistical procedures, there are times when you calculate just the probabilities of particular outcomes, such as a Bayesian update of a prior distribution. It's about $4$ times as likely to have a $31-19$ outcome if $A$ is actually a $60-40$ favorite rather than even, so you would strengthen your estimate of the probability that $A$ is a $60-40$ favorite by a factor of $4$ relative to the probability that $A$ and $B$ are even, not the ratio between the probabilities of observing events at least as extreme.