Hello,
I have 2D fixed joints on my UI buttons as shown below:

I have extra code for the movement and stuff but in essence, each of these is in a 2d “train” using fixed joints. I don’t understand though, why isn’t Orange being moved down too since it’s attached to blue, it’s anchor is on blue? Shouldn’t it be attached and moving when blue moves? Instead I get the picture below…

So there are a few solutions for this. Basically whatever you are trying to do with physics is a terrible idea and won’t work.
You keep using the word train, but I have never heard of the word train to describe a foldable list. This is a tree view, not train.
What you want is that each node of your tree be able to calculate its height, kinda like this:
float GetHeight()
{
if (closed)
return (self_height);
else
{
float height = self_height;
foreach (var child in children)
height += child.GetHeight();
return (height);
}
}
Now you can calculate the position of any element.
But realistically, just use one of the dozen tree view package: