There are 12 notes in total.
However only 7 are used in a major scale.
Pianos are in C major, so the notes used in the scale are white and the remaining 5 are black.
As for why they are in that specific grouping, that’s just due to the definition of a major scale.
Major scales are defined as:
1) starting note
2) note after next
3) note after next
4) next note
5) note after next
6) note after next
7) note after next
8) next note and we are back to the starting note but an octave higher.
The notes that are skipped are the black keys and this is why they are in the 2, 3 pattern.
Latest Answers