How to Build a Wall
Build your wall out of stone blocks. On the second level of stone blocks, carve out fortifications. Make sure you carve fortifications don’t construct fortifications otherwise you won’t be able to build on top of them. Carved fortifications include the floor tile for the z-level above them just like walls. I’d recommend you build the corners first. You should probably construct an adjoining floor and the same level as the fortifications otherwise you’re going to need to lay down the wall blocks in order, one at a time. If you lay down a whole section of wall with no alternate routes to get to the tile Dwarves will build walls that block them from building the rest.
Don’t build your walls out of wood or raw stone (raw stone takes forever to haul). Always use stone blocks.