The key of C is clearly related to the scale of C. That's where 'C' comes in. Called 'C' because that is the hub, centre, home, et al of both the key and the scale. In Western music, there tends to be a centre to a lot of music - it's somewhat like a journey. It starts at home, goes on various visits, and eventually returns. This can often (but not always!) be felt in the music itself. The beginning is obvious, and establishes 'home', and at various points along the way, it will return to that 'home', and could even be construed to finish there, at that very point. Of course, it's often a temporary drop back into the house for something, and we're off again.
The main notes that are used for this most often come from the set called diatonic, and all belong naturally to that specified key, so when put into order, as humans like to do, they constitute a scale.
Just as when on a journey, we sometimes take a detour, music can go off at a tangent, usually just a little, and move temporarily into another key, often related to the original, thus changing only a few notes. Modulation is its name, and just like the journey, it gets back home via a different route.
The majority of pieces will be in 'a key', and thus use the diatonic notes from that related scale to sound that way, but sometimes a twist in the journey will necessitate other notes (which by definition are from other keys/scales) being used. So just because something is 'in C', doesn't mean it's restricted to using only those seven notes that constitute that key or scale.
Chords? They're closely related to the scale notes, and a lot of the harmonies in a piece will reflect that in the notes making up those chords. But other notes can and do get used. Out of the 12 available, 7 are diatonic, leaving another 5 to colour the tune and its harmonies. Thus chromatic. Serendipity on the journey! And, as oft said - if it sounds good, it usually is! Theory can explain that, but does it really make any difference?!