So, I saw iNcontroL do this on his stream last night and I wish I had captured it for you because it really illustrates why this is such an important move: It controls the point of attack.
Back in Broodwars it was very common for your buildings to form a nice arc in front of your mineral line. The reason being that back in those days, every race had powerful melee and ranged units very early on. As a result, the arc allowed a player with ranged units to control where the opponent's melee units would attack in an artificial choke.
Starcraft 2 differs from Broodwars in a number of important ways: Smaller ramps at all naturals, mean you have a natural choke at every main base. Additionally, smaller bases mean that its easier to use buildings to create a wall to your natural choke, or from that choke to your natural expansion. This creates the line phenomena you observed, which has replaced the traditional arc
The reason you see players do this largely against Zerg (and less so against other races) is because the balance of Ranged/Melee is now distinct amongst the races. Terran have a fairly ubiquitous ranged early army, where as Zerg's army tends to be almost always Melee (or short ranged) early on. Though some players would rather opt for a Wall-In, that has disadvantages, and often is not practical for expansions. As a result, it is often a better idea to build your buildings in a line (especially warp gates, where it doesn't matter where you put them).
Finally, let's get to the reason that building these great walls is a good idea. If you have a range advantage on your opponent (or even if you both have a lot of short range), then if he attempts to bust your wall, you can harass him without taking damage to your army (your wall absorbs it instead). Most enemies will almost immediately realize why this is disadvantageous and withdraw. For them to attack you, they're forced to run around the wall (sometimes taking damage in the process), and engage at an artificial choke point. The Choke has long been known to give an advantage to the force with superior range, and since many natural expansions lack a choke, this artificial choke gives you a new advantage.
Whether or not you choose to wall-in, its important to know why you opponent might, and understand what its trying to accomplish. Usually the advantage provided by these walls starts to disappear in the mid-game, as players gain access to more ranged units and people start putting their army in front of their wall.
Its worth noting that recently a number of Zerg players have shifted to what is called a high economy baneling bust. This is a move specifically targeted at these kinds of walls (and more general wall-ins). This utilizes an unusually high number of Banelings to break the wall, followed up by rushing Speedlings into the natural Mineral line. As a result, its important you keep your army at the part of the wall closest to the enemy, so you can catch this bust in action, and only move towards the choke when your enemy does.