When deciding if you want to wall in you need to consider a few things:
1) Is your opponent likely to be aggressive? If so you probably want to wall in to prevent the early harass. It is hard to guess what your opponent will do so early, but scouting is very important and seeing a six pool is a clear sign of early aggression. So the key is to scout your opponent early to know what he is up to.
2) Do you want to be aggressive from the beginning? Then perhaps you don't even need to build a wall. Of course you really need to have a good build and micro. But a proxy barracks helps immensely when you want to harass your opponent with reapers or a bunch of marines early on.
3) Consider the map - is it large or small? On small maps, rushes are much more effective since you can get to your opponent fast. On large maps, where there is a big distance between you and your opponent rushes are much weaker, since by the time you get to your opponent he already has some forces (and probably more than you sent).
3) Does your main base have more than one entrance? If so, walling in is much less effective, since you still need to guard that second entrance.
4) Walling in has also other disadvantages - you have most of your forces and static defense on one place. So it is much easier to harass your mineral line with banshees/mutas etc. Also, Colossi can easily bypass your defenses and roast your base while you are unsieging your tanks... It also reduces your mobility.
5) On some maps your natural expansion is much easier defended than on others. Many high level players build some kind of a partial wall under the ramp leading to their main - this servers two purposes - it still is a wall that can help fend off early attacks, but at the same time does not reduce your mobility and allows for fast expansion which is then much easier to defend.
6) If you wall in very quickly, you can prevent your opponent from scouting your base. This can lead to a small advantage if you were able to see what he is doing. Before he can scout your base (with overlords/changelings, scan or observer/phoenix hallucination) you can do something nasty - like a fast banshee or whatever. Remember though, you really need to see what he is doing to make something out of this small advantage.
This is not an exhaustive list and is intended only to serve as a guideline what to consider when playing Terran (some of the things apply to Protoss as well, but i play mainly terran...). Deciding whether to wall in is a matter of preference and play style and is also affected by the map, your opponent and other factors. Use the advice in this answer to help you make a decision but do not follow it blindly.