I guess the square is filled with a Freeform gradient.
If so, the reason for the issue is that Freeform gradient objects have extended bounding boxes for some reason (you can usually see it by turning on the Use Preview Bounds option in the Align panel).
You are facing this (mis-)behaviour since the bounding boxes are the basis for the "Fit to" commands.
Sorry for the late reply. I hope the suggestions our experts shared earlier helped resolve the problem. If not, kindly confirm the version of Illustrator installed and share a sample file, so we can investigate further.
I guess the square is filled with a Freeform gradient.
If so, the reason for the issue is that Freeform gradient objects have extended bounding boxes for some reason (you can usually see it by turning on the Use Preview Bounds option in the Align panel).
You are facing this (mis-)behaviour since the bounding boxes are the basis for the "Fit to" commands.
Yes, I think this was the “issue”. I tried with a solid color and the resize artboard matches perfectly with the size of my selected object. Thanks for explaining.