When building something, it tends to deform the ground somewhat. Things like castles have a large footprint and so tend to deform quite a lot. Stone walls built before this will break up unnaturally, and don’t adopt to the new terrain properly. So to clarify the bug here, is that, although the walls change for the new terrain, it does not follow its normal “modular shape”, where the wall is smooth up to a certain point and where it turns into stairs. Instead, the entire portion of that wall will become jagged.
This also happens before a structure is built, leading to the awkward ability for someone to select a unit from afar and build the initial foundation, immediately deforming the ground–deleting the foundation will not return the ground to how it was before, freely allowing the player to deform the map at no cost.