In any system, players on both teams have to be in the proper rotation order at the time of the serve but once the serve is contacted, they can switch positions. In the 4-2 the setter in front row switch to the middle as soon as the serve is contacted, then stay in the middle until the rally is over. For serve receive when your setter is either left front or right front, most teams will do a stack on that side so the middle front is passing behind the attack line and closer to the middle of the court than the setter, and that would put the middle front in position to hit from that side. When the setter rotates to the middle front position, no switch is needed because they are already where the setter would go. Once the second setter rotates to the front row, the same thing happens except with a different setter.
The previous answer is wrong to say that passes should be based on where the setter is located - passes go to a position near middle front and it is up to the setter to get to that spot before the pass does, and this is regardless of whether you run a 4-2, 5-1, or 6-2. There is no such thing as a 6-1 offense.