It is mathematically possible for a universe to be shaped this way, but not our Universe. Our Universe is as close to flat as we can measure right now, though it’s only possible for it to be very slightly curved, considering the wiggle room we have remaining on our measurements.

The universe that you describe could be round, donut-shaped or cylindrical; some shape where at least in one direction, it connects back to itself. These aren’t your only options for a universe - you could also invent a saddle shaped or other, more exotic shape to place your universe in.

For now, let’s roll with a cylindrical universe. And let’s put a star somewhere on the surface. If the light from this star is going along the length of the cylinder, all it can ever do is go out, because the surface is flat in that direction; there’s no curve or loop. This flat, uncurved behavior is how we believe our Universe behaves in every direction. Light in our Universe departs its star, and travels in a straight line forever (as far as we can tell) unless it is intercepted by another astrophysical object, another star, planet, or telescope detector.

To read more, click here.