Guest worker visas were intended to work exactly like that. E.g, in Canada they were inviting Thai or Vietnamese workers to pick up fruits and vegetables during summer, and the workers would come work for 5-6 months then go back. In the beginning, the programme worked as intended and it allowed a path to immigration because very few wanted it in the first place, but soon it started being used by people who planned to immigrate from the very beginning. H1B was the same.