Do you have the settings correct to ensure the player collides with the polygon?
And when you move the player, are you using move_and_slide() or are you manually changing their position?
Also, if you have a Camera2D node on your player you can set the Top, Bottom, Left and Right boundaries in the Camera2D → Limit section of the inspector. This will keep the camera from moving out of the scene.
Those properties can also be set via code using the left_limit, right_limit, etc properties.
But it does sound like using move_and_slide will fix your initial problem of not having the collisions stop the character.