The Node Curve to Mesh
does not offer a direct way to align the face caps according to your wishes, so you would have to modify the caps accordingly after converting the curves into a mesh.
The Raycast
node will help you with this.
It's something like this:
First, capture the Endpoint and the Curve Tangent on the (resampled) curve. These values are adopted in the geometry when using Curve to Mesh
and can then be further processed.
Then separate the top face using this selection and apply the Bounding Box
node to it. This will give you a box that is horizontally aligned and completely encloses the face.
By subsequently separating the uppermost face from this box by comparing the face normals and scaling it up a little, you get a plane that you can use as a limit for moving the end points.
Finally, apply the Raycast
node and use the previously saved Curve Tangent as the Ray Direction.
(Blender 4.2.0+)