If you use Scale to change the shape of a rectangle, then the stroke proportions will change. If the Rectangle is a Parametric shape with a size value, you just change the size, and the stroke will stay constant.
If the Rectangle is a vector path, you have to use a complex expression to change the size of the path based on a slider or point controls, or you have to select the vector path and use the Transform tool to change the size manually.
Attached files are a pain to look at. Please embed them by dragging them to the reply field or using the toolbar. Cropped screenshots that don't show us the modified properties of the problem layers are pretty useless for diagnosing problems. I am only guessing that the rectangle you are showing is a Parametric shape created with the Rectangle tool.
I use this expression many times but recently, I noticed in After effects 2024, it reports "Error: Couldn't turn result into numeric value". Does anyone know how to perfect it?