Here is output from Minitab's test comparing two proportions.
Suppose you took 39 buttons from Box A, of which 22 are red (for a sample proportion of $\hat p_1 = 0.564).$
and you took 37 buttons from Box B, of which 27 are red (for a sample proportion of $\hat p_2 = 0.730).$
These two sample proportions may seem quite different, but sample sizes are small, and such a difference might well have happened at random sampling from boxes with the same proportion of red buttons.
Specifically, the P-value is $0.132 > 0.05,$ so the sample proportions are not significantly different at the 5% level. This test, which uses a normal approximation, is explained on the NIST site.
Minitab's output also gives results of Fisher's exact test, which uses a hypergeometric distribution and also does not find a significant difference at the 5% level.
Test and CI for Two Proportions
Sample X N Sample p
1 22 39 0.564103
2 27 37 0.729730
Difference = p (1) - p (2)
Estimate for difference: -0.165627
95% CI for difference: (-0.377043, 0.0457882)
Test for difference = 0 (vs ≠ 0):
Z = -1.51 P-Value = 0.132
Fisher’s exact test: P-Value = 0.156
If you are not interested in green buttons, then completely ignore any green buttons
you happen to encounter.
Some details of the Fisher exact test are explained on several
pages on this site and on various Internet sites. Here is one of the
pages on this site. The relevant Wikipedia page (as it appears 15 Jul '19), is thorough and accurate,
but may tell you more than you want to know.