Those flat/sharp notes between a whole step are enharmonic notes. A name of a note comes from a key signature, if it has sharps or flats.
Example:
E major (or C# minor) has four sharps in it (F#, C#, G#, D#), thus the scale is
E, F#, G#, A, B, C#, D#, E
Ab major (or F minor) has four flats in it (Bb, Eb, Ab, Db), the scale is
Ab, Bb, C, Db, Eb, F, G, Ab
In these two scales we have three pairs of notes, which are the same pitches, but the context is different: G#/Ab, C#/Db, D#/Eb