Why is the first bar a whole step? To me, it seems like both the first and second bar would be half steps since both notes are as close as possible to each other without them being in the same height position.
It's entirely logical of you to think that the musical stave would work like a graph of notes evenly spaced by semitone, with each position a semitone apart (this being the smallest interval normally considered in Western music).
However, standard musical notation doesn't work like this. Instead, standard notation shows a graph only of the notes in the C major scale (i.e. the white keys on the keyboard)*.
In your picture, the first interval is between A and B, which is a gap of two half steps. The second interval is from E to F, which is one half step. If you want to know why the major scale is like this, with these uneven gaps, then The major scale - why and how? and other questions on this site might be interesting.
Why is music theory built so tightly around the C Major scale? might also explain why, in turn, that scale is taken as the basis of the most common Western notation system.
However, all of this is only one way of representing music. There are other ways that work differently - if you google for 'chromatic staff', 'chromatic stave', or 'chromatic notation', you'll find systems of notation that represent notes more evenly, as you expected (though these are much less commonly-used than standard notation).
*these notes can then be altered by key signatures and accidentals to facilitate different keys and notes outside of the key.
Using the note names A>G, (7 names), and having 12 separate notes (including #and b), things are not straightforward. Looking at a piano keyboard will help it make sense. Each white key has a letter name; the blacks are #/b. So, starting at A, which is just to the right of the middle of the three blacks, the whites go up sequentially. That means that next note to the right (white) is B, as shown in your stave. Because there is another note between them, it's a tone - a whole step.
Going backwards to the E>F in your second stave, you'll see that there's no black between, so it's a semitone - or half-step. There are only two half-steps in music - between B and C, and your example, between E and F. All other dots on a line and the next space (and vice versa) will be a whole step - properly named 'tone'.
Generically the space between lines and spaces on staff is called variously: a step, second, or tone.
A-G (for English) are applied to the lines and spaces.
Super, super importantly you need to put a clef on the staff to know which letters are assigned to which lines and spaces. In your example you have a G clef which assigns the letter
G to the second line from the bottom.
The steps between the letters are not the same size!
There are two sizes of steps: whole steps and half steps. Or you can call them major seconds and minor seconds, or whole tones and half tones. You can also use "semi" rather than "half" like whole-tones and semi-tones.
All the steps are whole steps except those between
C which are half steps.
So, it is not a matter of visually how much space there is between notes on the staff, but about tones spelled with letters and how much spaces is between the letters.
Sharps and flats are used to change the letter positions by half-steps. So, for example,
B is a whole step, but the
A can be raised a half step with a sharp so that
B is a half step. Those sharps and flats can come from either a key signature or from accidentals added within the score.
As close as possible on the staff does not translate to as close as possible in frequency or pitch. The natural notes (C, D, E, F, G, A, B, C) are separated in frequency in the following pattern, (W, W, H, W, W, W, H). In more detail the intervals between consecutive notes are as follows.
C to D = Whole step (W)
D to E = W
E to F = Half step (H)
F to G = W
G to A = W
A to B = W
B to C = H
This is how the major scale is structured regardless of music notation.
Standard music notation places the natural notes on a staff or grid so that each line and space corresponds to a note in sequence. For the treble or G clef the notes on the staff are as follows, from the bottom line to the top line.
E, F, G, A, B, C, D, E, F
The sequence starts on the bottom line and lines and spaces are included. The notes on lines only are
E, G, B, D, F
and those on spaces only are
F, A, C, E
The interval pattern in the major scale is more fundamental than music notation. The notation treats each note equally (as you point out) but the natural scale is not built from only one interval. The two half steps are (E, F) and (B, C).
The notes on the stave do not indicate whole or half step intervals except when a sharp or flat sign is included. The answer to the question posted here is in the understanding of how different scales are constructed, major, minor, etc. The notes on the page only represent the notes of the scale in question. Look to the Key signature at the beginning of the piece for that information. If the key signature were to indicate the F to be Sharp or the E to be flat, the individual notes would appear on the stave in exactly the same relationship to each other but the interval between the tones would then be a whole step and the half step position would be moved accordingly.