If we have a G flat a natural gives a G, if we have a G sharp it gives a G, but what if we have a G double flat or double sharp? Especially if we are working in a key where G is already a flat or a sharp.
Remember your order of flats/sharps and that a flat or sharp is a "half tone" step
The order for flats is
B E A D G C F
Sharps are backwards
F C G D A E B
Among other things this can be used as a guide of rarity. Under normal circumstances, to have a B# sound good, you need to also be playing F# C# D# A# and E#.
Now when applied to say a Piano, there is no B# key. Half a "step" up from a B is a C. So to play a B# you would just play a C.
Now Back to your question, it's rare but not unheard of to have a "double" accidental on pieces that are transposed poorly, or as a way of shoving more voices in the same staff.
So an F## would be played as G (F + two half steps up).
I have never seen this in a well transposed piece. (Cramming more voices on a staff, or using F## instead of a G)
What is more Common is something like a A♭ major scale. B,E,and A are flat (order of flats)
So you get something, special in beginner pieces like
B♭, C, D, E♭, F, G, A♭, B♭
If written as
These are not double flats, there just reminders to play flats.
Also in the second measure these are not double flats.
Here in this example we have double flats.
C♭♭ is really a B♭ while the B♭♭ is really a A natural
C down half is a B down half is a B flat
B down half is a B♭ down half is a A natural
Lastly, I have seen, though rare, writing like this.
These two measures sound the same, but the first, is in some opinions easier to read. Keep in mind the second double flat isn't needed, I just included it for demo purposes.
Normally when people write music in this style (example 3) it's due to a beleife that all As in a A flat major piece should be flat, but the music calls for a an A natural. i.e. It's a writing style, not a totally new note. This is fairly common. Even more so in keys that have many flats, but music that needs a "lesser" (more common) flat to be played neutral.
A more contrived example would be something like
In the last measure, notes 3,4, 7, and 8 are all natural, while, 1 is flat because of the key signature, and note 5 had to have the flat reapplied to cancel out the natural from note 3.
All accidentals apply to the rest of the measure unless otherwise changed. So if we take out the naturals, You would play A♭, G, G, G, A♭, G, A♭, A♭.
A natural sign always completely cancels any accidental that may be or have been on a note, and the note is played natural.
A G natural that comes after a G# is played as a G natural. A G natural following a G double sharp (Gx) is also played as a G natural.
Note that all the accidental symbols are treated the same way: they are absolute. A G# written after a previous G# is not played as a Gx, it's just played as a G#.
This paragraph in the Lilypond (notation software) docs might be relevant:
In accordance with traditional typesetting rules, a natural sign is printed before a sharp or flat if a previous double sharp or flat on the same note is canceled. (To change this behavior to contemporary practice, set the extraNatural property to f in the Staff context.)
(the first measure corresponds to the "traditional" behaviour, the second to the "contemporary" - the played notes in both measures are the same, and they don't depend on the key)
This implies that:
To turn a double flat into a single flat (regardless of the key) the traditional practice is to use a natural-flat pair.
Alternatively (and more contemporarily), the natural can be ommited: a single flat is enough.
A single natural sign always produces the natural note (regardless of previous accidentals or key)