A scale is a named set of notes. Here's a $C$-major scale.

X:1 L:1/4 K:C C D E F G A B w: c d e f g a b

The order doesn't matter -- it's just about the notes. Here's a $G$-major scale.

X:1 L:1/4 K:C G A B c d e ^f w: g a b c d e f♯

If you compare the two, they have all the same notes except for one. $C$-major has an $f$ where $G$-major has an $f\sharp$. Why does that turn it into a completely different scale? Well, the names of the scales have two components: the root and the character.

$$\underbrace{\quad G \quad}_{\text{root}}\quad \underbrace{\text{ major}}_{\text{character}}$$

The character tells you which intervals belong to the scale, starting from the root. For major scales, the intervals are:

$${P1, M2, M3, P4, P5, M6, M7}$$

Here's how we apply this to the $G$-major scale:

$$\begin{aligned} g &+ P1 = &g\\ g &+ M2 = &a\\ g &+ M3 = &b\\ g &+ P4 = &c\\ g &+ P5 = &d\\ g &+ M6 = &e\\ g &+ M7 = &f\sharp \end{aligned}$$

And to the $A$-major scale:

$$\begin{aligned} a &+ P1 = &a\\ a &+ M2 = &b\\ a &+ M3 = &c\sharp\\ a &+ P4 = &d\\ a &+ P5 = &e\\ a &+ M6 = &f\sharp\\ a &+ M7 = &g\sharp \end{aligned}$$

You can construct the major scale for every one of the 12 notes in this way. You can also build different kinds of scales with the same root but different characters. Minor scales have this set of intervals:

$${P1, M2, m3, P4, P5, m6, m7}$$

Applied to a root of $g$, we get the $G$-minor scale.

$$\begin{aligned} g &+ P1 = &g\\ g &+ M2 = &a\\ g &+ m3 = &b\flat\\ g &+ P4 = &c\\ g &+ P5 = &d\\ g &+ m6 = &e\flat\\ g &+ m7 = &f \end{aligned}$$

Here's what $G$-minor looks like on a staff:

X:1 L:1/4 K:C G A _B c d _e f w: g a b♭ c d e♭ f

Notice that for all the scales I have shown you so far, the set of notes you end up with have exactly one note for each letter -- it may be a $\flat$ or a $\sharp$, but every letter is represented. There is no golden rule that says this has to be so. There are scales that do not have this property, but many of them do.

Another thing to think about is why we choose to use $e\flat$ in the $G$-minor scale and not $d\sharp$. They are the same notes -- is there a reason to pick one over the other?

Well, yes, they are enharmonic equivalents. But the intervals in the pattern bag for minor scales have a $P5$ and a $m6$, so when constructing the scale we have a 'perfect' five-note distance (a $P5$) and a 'small' six-note one distance (the $m6$), not an augmented five-note distance (which does exist). So, we arrive at a $d$ and an $e\flat$. It's nice to have this consistent way of doing things so that our pattern-loving brains can get good at reading sheet music.

As an aside: you can end up with notes with double sharps or flats like a $b\flat\flat$, but at that point fortunately most musicians are practical enough to accept the enharmonic equivalent notation of $a$.

To finish off this topic, here's a table of four of the most common scales. Note: the minor scale that we mean when we just say 'minor' is formally called the 'natural minor' scale.

Major${P1, M2, M3, P4, P5, M6, M7}$
Natural minor${P1, M2, m3, P4, P5, m6, m7}$
Harmonic minor${P1, M2, m3, P4, P5, m6, M7}$
Melodic minor${P1, M2, m3, P4, P5, M6, M7}$
Dorian${P1, M2, m3, P4, P5, M6, m7}$

It can be helpful to picture a decision tree when thinking about scales. In this mental model the Dorian scale is usually placed in the group of minor scales because it has a minor third, an important characteristic that we will see again when thinking about chords.

graph TB; Start--m3-->m[Something minor]; Start--M3-->M[Major]; m--m7-->nmd[Natural minor or Dorian]; m--M7-->hmmm[Harmonic or melodic minor]; hmmm--m6-->hm[Harmonic minor]; hmmm--M6-->mm[Melodic minor]; nmd--m6-->nm[Natural minor]; nmd--M6-->d[Dorian];

That's all for scales for now!