If you want to build a stone or wooden wall around for example, aTC following its grid, it bugs out and doesn’t work properly. However, placing regular houses alongside one side, shows that it is possible. The mechanic seemingly doesn’t work properly when attempting to build alongside any structure’s sides.
The first clip demonstrates what happens when you try to draw a wall across normally (the bug).
Here is how it probably should be working through a workaround.