In more detail
Manufacturing imperfections make each sensor pixel respond very slightly differently. Averaging many photos from one camera reveals that pattern, and a questioned photo can be tested for it. Heavy compression, resizing and editing weaken the match, so results are probabilistic, not proof.