The basic idea
A capo clamps across all six strings at a fret. It acts like a moving nut, raising the pitch of every open string by the same amount. When you play a C chord shape with the capo on fret 2, the strings are now tuned two semitones higher, so that shape sounds like a D chord. The shape stays the same. The pitch goes up.