To clarify:
sometimes, looking at chords helps. most chords can be stacked into groups of 3rds. so, for instance, in m. 3, we have Gb in the bass and a Bb against Db dyad in the RH. Bb has to be Bb because that's in the key signature and it's not a chromatic pitch. So, our options for how to write the Db and Gb are:
Bb, Gb, Db
Bb, F#, Db
Bb, F#, C#
Bb, Gb, C#
only one of these allows a verticality that stacks into 3rds, and that's the first one: Bb, Gb, Db stacks to Gb, Bb, Db which is a series of thirds
ok so Bb-Db-F# is technically also a series of 3rds but you (
generally - there are exceptions, such as certain fully-diminished 7th chords and
certain augmented 6ths) don't usually want to mix sharps and flats in a single sonority, so here Gb is the appropriate note.
another general rule: Series-of-thirds will have their members related by either a minor 3rd (3 half steps and a difference of 3 note names: ex Bb-Db) or a major third (4 half steps and a difference of 3 note names: ex Gb-Bb). this is how you can tell Db-F# is probably not the 3rd you want, since it's an augmented third (5 half steps) as opposed to Gb which would form a major third under Bb