Welcome to Android Central! If the phone is brand new, I wouldn't waste too much time trying to troubleshoot it--bring it back to the store, show them the problem, and ask for a replacement.
If for some reason you can't bring it back, you could always contact Samsung for warranty repair or replacement. If you still want to try troubleshooting, then boot into Safe Mode, which prevents all 3rd party apps from opening. If the camera is still glitchy, then it's a problem with the hardware or the firmware, and you should definitely get it replaced or repaired.
https://support.t-mobile.com/docs/DOC-11473