Each note in a key or scale must have its own letter.
Most Western scales have 7 notes. Including those with a sharp or flat in their name, most notes have two possible names.
We have 7 letters for note names and 7 pitch positions per octave on a stave. It makes sense that each note in a scale has a different letter as it’s name.
(Graphic, dots, D major scale with wrong crossed out and right notes)
Music notation is very visual. We can see the notes climb and descend as the melody itself climbs and descends. As we can see from the two versions of D major below, if two different notes in a scale share the same note name there are two different pitches sharing the same place on the stave and needing constant accidentals (sharps/flats/naturals) to show which is which. There is also one unused position, leaving a gap in the visual that we don’t hear.
(Sib graphics of D major melody, wrong/right notes)
If there are two possible names for a note, always choose the name that’s not used by any other notes in that key or scale.