Accidentals appear depending on voice shown

Can anyone explain this to me (I’m sure there is some logic to it);

Change bar 1, LH, to voice 1

The last chord in bar 2, RH, gets an additional accidental.

Change bar 2, LH, to voice 1

The last chord is “back to normal”.