The boxes are just convenient places to play. For instance in A pentatonic minor, your fingers can reach from the 5th to 8th frets fairly easily, so that's box 1. Your fingers can reach from the 7th to the 10 fret fairly easily, so that's box 2. Etc.
View attachment 16494
In the key of G, the notes form the same pattern over the fretboard, it's just that everything's moved down two frets. The pattern that used to be on the 5th fret is now on the 3rd, etc. Same with all the other keys.
View attachment 16495