The precise term is anachronism—a chronological inconsistency where an object, event, or custom appears outside its proper historical era.
Writers sometimes deploy anachronisms deliberately—for satire (A Knight's Tale), fantasy blending, or thematic resonance. Accidental ones are continuity errors. Famous examples include the Starbucks cup in Game of Thrones or a smartphone glimpsed in a period drama.
Whether a joke or a gaffe, anachronisms remind us that every story is built on a timeline—and breaking it has consequences.