In (a), it is a backcourt violation.
When A2, while holding the ball, lifts the foot which was in the backcourt, the ball is now in the frontcourt. When A2’s foot then touches in the backcourt, it is a violation.
In (b),
when A2 lifts the foot which is in the frontcourt and places it down in the backcourt, the location of the ball has not changed. The ball is still in the backcourt and no violation has occurred.