In Starcraft 2 Protoss walling in strategies can be effective. There are certainly reasons for it and against it. If you are more of a defensive player, for instance, then building a walled in settlement may be a good idea to you, but if you're more offensive, then it can still be done in certain cases. Being walled in is certainly a good way to defend against Zerg players for instance, but can be a poor strategy against Terran players who can do some devastating area of effect damage from afar with their Siege Tanks.
Why is walling in with Protoss an effective defensive measure against Zerg players? Zerglings, and other ground units that the Zerg can field can be rather effective in large numbers due to auto-surrounding. When alone a single Zerg unit typically does not inflict much damage, but they are rather quick and if surrounded by many of them an unit receives quite a bit of damage.
Walling in your entire base is a good way to deal with Zerglings for instance because if they want to get at your buildings and workers they will need to get through your walled in defensive line, which makes them swarm at your terms. Creating a path one unit wide allows you to deal with Zerglings one at a time, which can aid in defending. Early Protoss walls are usually created at the top of a ramp and consist of a Gateway, Cybernetics Core and a Zealot ordered to hold position.
Also, walling up ramps or small areas with Protoss is indeed a good idea against the Zerg. They have easily some of the best units available but also pay an arm and a leg for them. This means nothing though out in the open if these units are flanked easily and swarmed. But, if these units wall in or go behind a choke point and fight on their own terms it can be like going toe to toe with a group of Spartan warriors in a cramped avenue.
Also, the Protoss have a rather iconic building, the Photon Cannon. These cannons are great at certain times and make for a good early game defense. They're great because their rather versatile, they can attack both land and air units and are shielded. They can also be purchased for a relatively low cost and they can help wall in areas creating barriers that can save you time and whittle down your opponents as they approach.
When it comes to walling in tactics the Protoss are almost quintessential. They can be a highly defensive civilization to play and can be very successful at fighting battles on their own terms. No other civilization have as specialized forces as the Protoss do. They stay true to their ancient advanced race lore through their units who are all rather ornate looking and are also usually equipped with rechargeable shields, or occasionally cloaking devices.
Walling in a base can be difficult to do, however, and can work against you as well as for you. Moving your troops outside of a walled in settlement, for instance, can be difficult as the lanes you create can slow or stifle units depending on the nature of that unit and the lane you created between buildings.
Still creating such lanes and subsequently transforming your settlement into a fortress, is certainly an interesting strategy that can work.