If an infraction is discovered immediately after a batter completes his appearance, then the umpire considers that batter and the previous one.
If the infraction is discovered during a plate appearance (that is, a pitch has been thrown to the current batter), then the umpire considers the current batter and the previous one.