In the below sheet music B is marked as flat however the only notes played are
g g g d e c C. Is that just a typo on the part of the person who made this image and it should be on the upper C or am I missing something else?
Sharps and flats in the key signature are one indication as to the key of a piece. Lacking those notes in the actual music is irrelevant. For example, play all the white notes on a keyboard in order from C to the next C an octave higher. Now do the same from F to F. Hear how it sounds weird on the 4th note (B)? That's because you need to play it in the key of F. Now try playing F to F again but this time play Bb instead of B.