- The notes C, E and G played together are always a C major chord.
- A C major chord is always the notes C, E and G.
- Fret that shape on a guitar, and it's always C Major.
When you play in a different key, C major's role changes.
If you're playing in the key of C major, then C major is the root chord - the I. F is the fourth chord (IV) and G is the fifth chord (V). Lots of simple songs are based on I,IV and V, so you may recognise that set of chords.
If you play in the key of G major, then I is G major, IV is C major, V is D major.
So, in the key of G when you see "C" on the song sheet, you fret the same shape, and play the same notes as you did when you saw "C" in a song in the key of C. But this time the C is playing a different role. It is the IV. It "feels" different; the listener is waiting for you to return to root chord, G.
Look through your songbooks and see if you can spot I,IV and V in other keys. Beginner guitar books tend to use the keys C, G, E, D, A.
Edit to add:
Here's an analogy.
Think of your C major chord as a circle. It doesn't matter where you draw a circle; you always draw it the same way. Seen on its own, it just looks like a circle. A C major chord just sounds like a C major chord.
The rest of the piece you're playing defines what that C major chord "does". The key of the piece is a fundamental part of that.
Because of the other lines drawn around the circle, it becomes the sun, or a football, or a planet, or a head, or a compact disk, or whatever the artist chooses. In the same way, the other notes you play around your C chord, make it take on different purposes in the music.