or use Extrude Along and use curves directly, which might be much simpler than measuring curve length then extruding by a Z vector that has same length as the curve themselves:
Boundary Surface component is changing the order on which some of those rectangular surfaces are created (see the difference in numbering on their area centroid when compared to the grafted+flattened version, which would work just fine as well)
the reason for that is Boundary Surface tries to get as many planar surfaces as it can from the supplied curves, but the function will for sure reorder stuff in a different way while those surfaces are created
if you don’t want go through that, you can also just create planar surfaces instead of rectangles: