Notes have multiple names because of the structure of scales. There are spaces between notes called half steps and whole steps. Between F and G, there is one whole step. Therefore, an F# is raising an F by a half step, while a G flat is lowering a G by a half step. This makes the notes meet in the middle to be the same note. However, when writing music the same note may be written in different ways based on the key and which one will be easier for the instrumentalist or singer to read in sheet music.