A fixed row of boxes rolls past the stamper, one by one. When the last one passes, the loop stops โ you can count them in advance.
๐ก for = you know how many. The belt has N boxes, so it stops after N. (No idea how many? That's the while carousel โ it spins until the music stops.)