I'm making a script, when I put it on google sites and press the button that changes the size of the script (Add n rows in the UI), the site does not suit the new page size of it, as I do so that it is automatically resized?
If you are saying that the UI adds n
rows to the widget, then you will need to resize the widget itself. Since the widget frame loads prior to the user adding rows, there really is no way to change the widget size after the page loads.
I might change my answer if you can provide more details on what your Apps Script does, but this is the general feedback I have based on how widgets are loaded on Google Sites.