Every dashcam has a built-in G-sensor. A G-sensor is a sensor in the dashcam that registers vibrations. In case you have an accident, the G-sensor will notice and the dashcam will save the current recording as 'emergency file' that cannot be erased. The sensitivity of the G-sensor can usually be adjusted in the dashcam's menu.
The way the dashcam saves the Emergency files differs from type to type. Some dashcams store the emergency files in a separate Emergency folder, others protect the video so it cannot be erased by the loop recording on the dashcam.