Allow a game object to stick to another game object's part?

Hey there! I need a help here. While working in unity, i need to find a way so as to allow one game object to stick to a part of another game object.

For instance, consider the blue square.

193788-img1.png

When I try to resize the layer behind it to which the square is attached, it moves out of the layer itself, but instead I want it to remain stick to the layer as in the place where hollow green square is.

193789-img2.png

How do I do that? Is there any better way of doing what I’m trying to achieve?

I think you can the the blue square a child of the layer that you are trying to resize…