I've modified my code a bit, just to remove that bug and clean it a bit. I've also added the posibility to "freeze" the object except the X axis even if B is a child of A (and you are moving A)
The scale is store in the vectors of the matrix itsellf (v1, v2, v3) the length of the vector is the scale in that particular axis.
Have a look at matrix fundamentals
so if you want to set the scale back to 1, you have to just set all the vector lenght to 1. In other words, you have to normalized those vector, or in a matrix you just normalize the matrix itself.
If you want to retrieve or keep the scale, you can retrieve the scale of on object's matrix with GetScale and apply with Scale (same link)
Don't over think how matrix works, just focus on how you can use them.
.off is the displacement information
.v1 is the x axis information about the rotation (where the vector is pointing to) and the scale (how long the vector is, it's magnitude)
.v2 is the y axis
.v3 is the z axis.
the identity matrix (no displacement, no rotation, scale 1) can be created with
With that if you only want to add the displacement information just add your information in .off
Just be careful that the axis v1, v2, v3 must be orthogonal