What difference does it make when to update the position of a component?

I’m trying to update the position of one of background parts. The goal is to move the most left background part to the right side of most right background part when it reach the some point (in my case it is -840). So I wrote this:

// Called every frame
void ABackground::Tick(float DeltaTime) {
	Super::Tick(DeltaTime);

	for (ABackgroundPart* BackgroundPartItem : BackgroundParts) {
		const FVector BackgroundLocation = BackgroundPartItem->GetActorLocation();
		float NewXPosition = BackgroundLocation.X + MoveSpeed * DeltaTime;
	
		if (BackgroundLocation.X <= -840) {
			const FVector LastBackgroundLocation = BackgroundParts[LastBackgroundPartIndex]->GetActorLocation();

			NewXPosition = LastBackgroundLocation.X + BackgroundPartWidth;

			// BackgroundPartItem->SetActorLocation(FVector(NewXPosition, 0, 0));

			LastBackgroundPartIndex = (LastBackgroundPartIndex + 1) % BackgroundPartsCount;

			// return;
		}
	
		BackgroundPartItem->SetActorLocation(FVector(NewXPosition, 0, 0));
	}
}

The problem is that when I use this code I get a gap between some parts (first and last):

But when I uncomment the commented lines everything works fine.

So here is the questions: What difference does it make when to update the position of a component?