There are musical notes. You probably have heard of them. Hopefully you know their names. The naming is based on a specific musical scale, using letters of the alphabet, and they are:
C___D___E___F___G___A___B___C
This is the C major scale, but it doesn't includes all the notes. It looks like we have 7 different notes because the C repeats itself, but this one has a higher pitch than the first (this is called an octave since it's the 8th note of the scale). The other notes exist between some of the ones in the scale above, and the naming used is a modification of the name of the note next to it, adding the term flat or sharp.
From one note to the next there is a distance, called a semitone (or half step), and from one note to its next octave there are twelve semitones.
From one note to the next there is a distance, called a semitone (or half step), and from one note to its next octave there are twelve semitones.
Notes C___C#___D___D#___E___F___F#___G___G#___A___A#___B___C
Semitone 0___1 ___2___3 ___4___5___6 ___7___8 ___9___10___11__12
The # on C# means it's a C sharp. A sharp notation is used to indicate that the note that is shown there is not the one that is really meant to be used, but instead the note that is a semitone higher.
But that is not the only way we can express accidentals. We also have this.
C___D♭___D___E♭___E___F___G♭___G___A♭___A___B♭___B___C
The ♭ on D♭ means it's a D flat. A flat is the opposite of a sharp, its pitch is one semitone lower. It's important to notice that C# is exactly the same note as D♭.
Now, you might have noticed that between B and C, and E and F there are no accidental notes. That is because they are already only a semitone apart in distance, leaving no space left for a new note in between., whilst for example C and D are a whole tone (or one step) away from each other.
The use of sharp and flat depends on which scale (for more on scales see Musical Scales) the piece is written and which notes are included in such scale. The ideal is to write each note in the C major scale (ignoring if it's sharp or flat) once without repeating and without skipping.
So let's say we have a scale with C, C# or D♭, and E (and F, G, A, B etc, it's a made up scale). We must use then D♭ instead of C# because otherwise we would be skipping D and repeating C.