It usually has to do with augmenting a note already sharped or flatted by the key signature, but the written note usually falls in the written chord, too.
Let's say you had a D# minor chord. That's D#, F# and A#. If you wanted to make it major, it wouldn't be D#, G, and A#, but D#, F## and A#.
Or, take a harmonic minor scale that already has a sharped 7th. To raise it another half step, you would double sharp it, or otherwise have two of the same written top octave notes.
Same aspect, a major chord of Cb, Eb and Gb would be made minor by double flatting the E instead of writing a D, which doesn't fit in the chord. B, D and F# would be the same chord in a different key, however!