How do scientists know the difference between new earthquakes and aftershocks?

It is partly a matter of definition, based on the sequence of events and on the magnitude readings and other accumulated data about a given large seismic event. Seismologists define not only aftershocks but also foreshocks.

Foreshock and aftershock are relative terms. Fore-shocks are earthquakes that precede larger earthquakes in the same location.

Aftershocks are smaller earthquakes that occur in the same general area days to years after a larger event or main shock and in the span of time before the level of seismic activity returns to the normal or background range.

The general area of a shock differs from fault to fault and is defined as being one to two fault-lengths away.

Aftershocks represent minor readjustments along the portion of a fault that slipped during the main shock. The frequency of these aftershocks decreases with time.

Historically, deep earthquakes are much less likely to be followed by aftershocks than are shallow earthquakes.