There was a recent case of materials of a stacked wall rotating, it looked like this.
After taking a closer look, I found that the brick material was rotated only on the walls with edited profiles. The stacked wall at the bottom had no surface pattern when the edited profiles were applied. To solve the issue, I added a surface pattern to the stacked wall family for the material to the proper orientation when the wall profile was edited. The mystery of the rotating materials is now solved.