This is a problem about managing multiple resolutions, aspect ratios and window resizing behaviours.
Open the Project Settings, go to Display › Window, scroll to the Stretch section, and select the Stretch Mode that best suits your needs.