Mechanical parts wear and break or become misaligned from abnormal wear. Rough handling can’t be ruled out. It’s not deliberate, we’ve all had it happen from time to time. The iPhone is in our back pocket and we sit down on it hard. Maybe it’s sitting on the passenger seat and the brakes get slammed on hard and it flies across the seat and hits the floor hard. Tiny misalignment of parts cause abnormal wear which can lead to premature failure. I’m not accusing, just pointing out how these things may happen.
Your iPhone has three distinct cameras, each with their own lens. One camera can break separate of the other two still operating normally.
You need to have Apple perform diagnostics on your iPhone. It can be done in person at an Apple Retail Store or at an Apple Authorized Service Provider. You can also contact Apple Support and request remote diagnostics.
If you’re in the US, please call 1-800-MY-APPLE, or outside the US, consult the support articles below. In Canada, call 1-800-263-3394.
Contact Apple for support and service - Apple Support
Genius Bar Reservation and Apple Support Options - Apple