What you have in your first picture is an e minor pentatonic scale. E means that the root note is E. Minor means that the "third" of the scale is a minor third. Pentatonic means that there are five notes per octave.
In the following picture, the root note E is colored green. In your E minor pentatonic scale chart, it is marked with the letter R for Root. The root note of the scale is the center of harmony for that scale.
The distance from any note to the next higher note of the same name, for example from an E to the next-higher E is one octave, twelve frets. You can play pentatonic scales even on one single string:
I recommend practicing on a single string, because that gets you familiar with the distances between scale degrees. In any minor pentatonic scale, starting from the root which is 0, there's first a jump of +3 frets, then two more to get +5, then +7, +10, +12 which gets you to the root note again. Or if you start from the high E and go left i.e. down, you get -2, -5, ... In other words, if you go 7 frets (semitones) UP from E you get a B note, and if you go 5 frets DOWN from E, you get B as well.
Scales being movable means that the same shape can be moved across the fretboard to obtain other scales with different root notes. In the following animation, we move the E minor pentatonic scale up five frets to obtain the A minor pentatonic scale. You move the E minor scale, it's not an E scale anymore.
The animation doesn't show it, but more notes come in from the left, to mirror what's happening to the right of the 12th fret. Everything repeats all over again exactly the same at the 12th fret, no matter what scale it is. In the following picture, there's the A minor pentatonic scale. As you can see, it's what you have in your first picture, but everything is moved five frets to the right, and wrapped around at the 12th fret.
Now look at the root note A on the highest string. What are the distances? They're the same as for any minor pentatonic. Root = A = 0, then +3 frets, +5, +7, +10 and repeat all over.
You select your root note according to the key of the tune you're playing. If the song is in E minor, you (normally) select the E minor pentatonic scale. If it's in A minor, you select an A-based scale. The root note is the center, the home base, the zero-point of your harmonic thinking. Key means the same thing - it's the harmonic center. "The song is in E minor" means that the harmony is centered on E as home base, and the "third" above E is a minor third.
Which position or "box" you select? Whatever you want or need for the melodic lines you play. What is comfortable, reachable, appropriate for what you want. If you want your lines to go higher, move to a position up on the neck to reach higher notes.
How did they construct the shape 1 to shape 5 boxes? Any minor pentatonic scale contains the following notes:
- Root, 1st, i.e. "1" or "R" in the pictures
- Minor 3rd, i.e. "♭3"
- Perfect 4th, i.e. "4"
- Perfect 5th, i.e. "5"
- Minor 7th, i.e. "♭7"
And then it continues. The scale goes 1, ♭3, 4, 5, ♭7, 1, ♭3, 4, 5, ♭7, 1, ♭3, 4, 5, ♭7, 1, ... You take every scale note exactly once, and don't skip anything. Start from the lowest note inside each position.
Using "boxes" is not the only way to construct pentatonic scale patterns for playing. We can make a scale on only one string. This is what the E minor pentatonic scale looks like on just the E string:
Or you could make a scale by using three notes per every string. Here's A minor pentatonic with three notes per string.
Not very easy to play, but why not, that's a scale. To play a scale run, you go up or down, using every scale degree exactly once, not skipping any.
The full diagrams with the whole fretboard full of notes is also a scale diagram in a way, but with multiple instances of the same pitch. In the positional boxes, there is only one instance of each pitch. ... 5, ♭7, 1, ♭3, 4, 5, ♭7, 1, ♭3, 4, 5, ♭7, 1, ...