Gaps to wall or backslash.
Before fixing this problem you need to understand the cause. Was the gap there when the home was delivered so it was probably caused by transport? Has it been getting larger over time indicating that the counter is pulling away from the wall or the wall is bending. If the wall seems to be moving, check it carefully inside, outside, above and below for water damage.
In a new home it is possible the factory used wet lumber that is bowing or warping as it dries out. The other possibility is that water is getting into the wall causing it to bow and warp; this obviously is a problem that needs to be fixed as soon as possible.
If the gap is 1/4 to 3/8″ wide then sealing it with caulk makes sense. If the gap is wider then stronger measures are required.
The goal of these procedures is to fasten the counter to the wall with enough force to pull the two surfaces together and keep them there no matter if they has or continues to be some force that tends to separate them.
Empty out the cabinets and locate the studs in the wall.
Is there a piece of counter support structure that you can drive a screw(s) through, into the stud? If so, you have just lucked out and will want to use some fender washers to provide more surface area for the screw to pull against without splitting the wood.
More likely you will find there is no part of the counter support over the stud will have to build something to do the job. You can apply a LOT of force when you drive these screws so do it carefully and gradually to make sure nothing splits or breaks.