In the US, boys and girls are allowed to participate in certain sports and transition between various competitive levels based on their overall maturity (height and weight, bone and muscular mass and strength, body composition, etc.). For example, playing badminton might be easier compared to going downhill equipped with full skiing gear and then carrying your skis uphill. If a student is not mature enough to accomplish the task, they should probably not be allowed to participate.
In contact sports, where the possibility of a direct impact with another player is imminent, assessing players' maturity becomes even more important. You simply do not want pre-pubescent boys to play against fully matured men, who could inadvertently or intentionally injure younger boys.
In team sports, where boys often change and shower together, it might be more comfortable if their overall development, including genital size and pubic hair intensity, is similar. Prepubescent boys might simply be uncomfortable being naked around older pubescent or postpubescent males, and vice versa, especially if they attend the same school.
For these reasons, various sports require students to achieve a certain degree of maturity, which is well correlated with genital development measured in incremental values from 1 to 5. In boys, a value of 1 is assigned when there are virtually no signs of genital growth and development and no pubic hair; a value of 5 is assigned to a male student displaying fully developed genitalia of an adult size and proportions, along with dense, coarse, and curly pubic hair.
When assigning a Tanner score to a male student, the practitioner will visually inspect the penile length and girth, the width and length of the glans, the thickness and width of the coronal ridge, testicular volume, pigmentation of the penile and scrotal skin, and the intensity, density, and coarseness of the pubic hair. These inspections are often very quick and do not require palpation, except that uncircumcised males are asked to reveal the glans to assess its development.
Does this help?
I agree with what you say (and you are correct) except I doubt comfort in locker rooms has anything to do with it. I think it strictly divided between competitive fairness and also the extent to which it is a liability issue in terms of potential injury by mismatching kids who, in terms of age and weight alone, might be matched against each other.