Each bond is free to rotate. The next carbon atom is one of four groups attached to the first carbon atom and projects at the tetrahedral angle. Its bond to the next carbon atom is also free to rotate and again projects at the tetrahedral angle. If this is not clear, you should find some models of atoms. The balls and sticks that represent the atoms and the bonds will not line up as in the arrangement labeled not correct in the sketch. If you have no models, you can do quite well representing carbon linkages with styrofoam balls and match sticks. Remember to space the sticks to get a regular tetrahedron. You might line up the balls so that they appear to be in a straight line when viewed from one angle, but they must zig and zag from another viewing angle.
The situation is entirely different when the carbon atoms are in a ring. Five atoms in a ring can have bond angles fairly close to the tetrahedral angle. Six-member rings do not allow good bond angles if all the atoms are in the same plane.
The next sketch shows a flat ring that is not correct (it is OK for benzene because double bonds put the atoms in the same plane). The angles for a regular hexagon are not close to the tetrahedral angle of 109 degrees. However, not being in the same plane makes it easy for the bonds to take the tetrahedral angle. There are two ways to bend from the plane. These are the boat and chair forms shown.
The hydroxyl groups on sugars interfere with each other so that the boat form or the chair form of a sugar ring may be favored. Both five-membered and six-membered rings can bend to give the tetrahedral angle, so both pentoses and hexoses form stable ring structures. We will not study these structures further except to say that they help to explain why sugars that seem to have very similar structures have quite different properties.