It’s not necessary to add constraints to the elements inside the stack view other than height if that is really needed. I suspect that the width constraint is causing your issue. Configure the stackView so that the Alignment is set to Fill, the Distribution is set to Fill and the spacing set to whatever you prefer and that should be sufficient.
Also when you post images of your code, use the built in Screenshot app rather than take a photograph. Photographs of code are very hard to view.
With the Mac ScreenShot App, you can capture the entire window, the entire screen or a section of the screen.
If you just want a small section, press Shift + Command + 4 which will change your mouse pointer into a set of crosshairs. Click and drag diagonally across the screen to capture the section you want. When you let go of the mouse button, the image will be saved to your Desktop and will be named something like “Screen Shot 2020-04-24 at 1.22.57 pm”.
Other options are available by pressing Shift + Command + 5 and an options bar will appear near the bottom of the screen.