If nothing interacts with the photon, conservation of momentum tells us it will travel (approximately) in a straight line.
When light does interact with a material, like a block of glass, the light bends because it travels more slowly in the glass. The direction the light travels is determined by the phase front (the line of peak amplitude) of the light wave. (a plane wave is a stream of parallel phase fronts). The light will always travel forward, perpendicular to that line, but if one part of that beam is inside glass (say, at the interface), then that part of the phase front moves more slowly than the part that's still in air, steering the light beam accordingly.
Of course, even in the vacuum of space, light doesn't quite travel in a straight line.
Due to its wave nature, light diffracts, or spreads out.
As one example, if you pointed a typical laser at the moon, its light would spread out so much that by the time it reached the moon, it would cover most of its surface. With better engineering, we can make that spot size smaller, but not to the point of having the beam be the same width as when it left the laser.