There are different issues here, so it's not easy to sort things out.
Basically the wall alignment works like this: You have a baseline only, which can be positioned any possible way in space. So it's not possible to tell which side is left or right. So what we try is to figure out a normal direction. When we have a baseline and a normal direction (basically a perpendicular direction to it, which indicates "the up side"), then we can consistently tell where left and right are, given the direction of the baseline. This is a very basic vector math cross product operation.
Obviously, if the direction of the baseline OR the normal is flipped, the right and left sides change. So indeed the direction in which you draw wall segments is important.
The normal direction can not always be guessed. If you have a (non-linear) polyline, for example, the normal direction is easy. But for a single line, there are 360° possible normal directions.
The wall object does a very simple guess in that last case, basically picking the one from these 360 that points upwards on the Z axis. But it can fail for any number of reasons too.
At the end I would say this: It fails often, indeed, many walls get inverted left/right sides, but it's a solid system that makes the walls behave consistently even if you move or rotate them in any possible position, allowing to use walls not only for "classical", vertical walls, but any other situation where you'd require a wall-like object. I think overall the system is valid.
Maybe we could refine it, though. For example, check against the current working plane at wall creation, try to guess better, an store somewhere if the above rule needs to be inverted