Just to add to Tim's answer: The Major chord has 3 notes: the 1st, 3rd, and 5th of the scale. If you look at the different chord types (Minor, 7th), you'll notice they take different parts of the same scale. This link will show you a description of the different chord types and how they are made up: https://www.edmprod.com/different-chord-types/
Your two diagrams are different for a few reasons:
- second one is color coded (obvious difference)
- first shows the notes, with either name (f# and gb are the same note with different names)
- second favours one note name (only f#). I'm not sure what the numbers there are: maybe what finger you should use?
I found the fretboard a bit cryptic until I tried something, which I recommend you try. Take a copy of your first diagram (without color), and find every instance of E - that's your root note. Color it red. Find every instance of the 3rd (G#) and color them all yellow. Find every fifth (B), and color it blue. You will get a clear picture of how notes are distributed in a pattern. Every scale works the same way, only the roots start elsewhere. If you play the chord in each different place, you can hear the difference in sound - it's the same chord, but as Tim said, a different voice.