I can't figure it out why F#(G) in the first red box is used
There should be no accidental, since there's an F♯ in the key signature. Both the Bach-Gesellschaft edition and the Neue Bach-Ausgabe print this F♯ without an accidental. (Both are available at IMSLP; note that this chorale, unusually, appears at the beginning of the cantata.)
F♯ is diatonic to E minor, so this is just a regular passing tone.
For the note to be F-double-sharp, it would have to be a double-sharp sign, which looks like a small
x. Accidentals are not additive; this sharp sign is just a notational redundancy that doesn't change the music.
Second red box...
I would analyze the entire second phrase, starting on the fourth beat in the example, in A minor. Lutheran chorales often have each phrase cadencing on a different degree of the scale, and it's frequently useful to consider the entire phrase relative to that scale degree. The first chord of that phrase comprises the pitches G♯-B-D-F♮, so it is
Analyzing the phrase relative to A minor means that the E major chords are not
i (which they can't be because
i is minor) nor even
V/iv. Similarly, the chord comprising B-D-F♮ is
ii°/iv. The E in the bass is an accented passing tone; the structural root is D. This leads us to an analysis of the cadence, ignoring suspensions and other contrapuntal details, as
ii♯6/iv - V/iv - iv, which can hardly be more standard.
If you're looking for a pivot chord, you might consider that the
I chord at the end of the first phrase (beat 3 in the example) is reinterpreted as
Finally, a word on terminology. "Melodic minor" is a scale. There's no such thing as a melodic minor chord, melodic minor key, or melodic minor tonality. "Melodic minor" arises from the tendency for the sixth and seventh scale degrees to vary in minor keys -- sometimes one sees the major sixth or seventh and sometimes the minor.
It is also interesting to note that the melody here is in B phrygian, even though the harmonization is in E minor. This provides another explanation for the frequent appearance of E major.