I can think of two possible causes:

Duet is mounted above a conductive surface, and the underside of the motor connector sometimes touches that surface.

A temperature-dependent fault on the Duet, most likely in the driver.