Question: what is the difference between a key signature and an accidental?
Answer: An accidental only applies to the note it specifies, at that octave, for that bar or measure. A change to a note in a key signature applies to every occurence of that note on the stave, at any octave, until the end of the piece, or the key signature is changed.