Watch the latch
With the door open, press the latch in with a finger and let it go. It should spring back out quickly. If it is slow or sticks halfway, the latch mechanism is likely the issue. If it springs back fine, close the door slowly and watch where the latch meets the strike plate on the frame.
Look for marks
Scratches or shiny wear above or below the strike opening tell you the latch is landing off target. That points to door sag, loose hinges or a swollen frame. New, thick weatherstripping can also push a door back so the latch never reaches its hole.
Short-term safety
If an exterior door will not latch, use the deadbolt if it still works. If neither secures the door, treat it as urgent, particularly overnight.
Hinges are a common culprit
Open the door and lift gently on the handle side. If the door moves up noticeably, the hinge screws may have loosened, letting the door sag so the latch lands low. Many homeowners notice this first on heavy exterior doors that are opened many times a day. Mention any movement you feel when you describe the problem.