The simplest way is to use the layout bounds with the scroll to behavior, it already does everything you want by default.
Otherwise, you'll need to define your own bounds and margins. You'll need four bounds, top, right, bottom, and left. You'll also want two margins, horizontal and vertical, or you can simply use half the viewport height and width as your margins. You can use the clamp() expression to keep the final value within a minimum and maximum value.
+ System: Every tick
-> System: Set scroll X to clamp(Target.X,LeftBound+(LayoutWidth÷2),RightBound-(LayoutWidth÷2))
-> System: Set scroll Y to clamp(Target.Y,TopBound+(LayoutWidth÷2),BottomBound-(LayoutWidth÷2))