so the purpose of a key signature is to instruct you as to which notes are sharpened/flattened in the piece? Does that mean in a key signature where the F is sharpened, a natural F can not occur? And wouldn't the key of Cb major and B major be the same thing? Why are there different key signatures for it?
Well, the key signature tells you what key the song is in and what sharps and flats are in it by default. It can be changed during the song, but after the measure's over it reverts to the default.
Actually, you can have a F natural. The composer will place a natural sign in front of it, just as a sharp sign appears in front of an fsharp. as for your Cb im not sure if there is one.... ill get back
The key of Cb (C flat) exists, and has 7 flats.

It basically is the same as the key of B, which has 5 sharps. That is, it consists of the same pitches, but notated differently.

The only time I can think that you'd use it is if you were in the key of Gb major, and you wanted to modulate temporarily to a 4th higher. You'd change to Cb, as opposed to B, since B is not one of the scale degrees in the Gb scale, but Cb is.