Newer STM32 (starting with 'L0/'L4 roughly 10 years ago) have error-check-and-correction (ECC) circuitry implemented within their FLASH controller. This is a useful feature to ensure FLASH integrity especially in long term, and almost a necessity these days due to the rapidly decreasing feature size thus increasing impact of FLASH leakage and crosstalk on its retention.
The FLASH ECC operates on the whole width of the FLASH word, i.e. the chunk of FLASH written/read at the same time (the actual width depends on the particular family/model, e.g. in 'L4 it is 64 bits). The FLASH array contains extra data (e.g. in case of 'L4 the actual FLASH width is 72 bits, i.e. there is an extra ECC byte for every 8 bytes), into whith the ECC checksum is stored. The extra bits are not accessible to the user.
The ECC operation is transparent to the user and occurs automatically. Upon each write hardware calculates the ECC checksum and writes in into the extra bits. Upon read the hardware uses the extra bits to determine if the data bits are unaltered. If there is a single-bit error, the hardware corrects it automatically; there is an optional (maskable and by default disabled) interrupt which can be triggered upon such event. If there is a double-bit (or more) error, this is not correctable, and hardware invokes a non-maskable interrupt (NMI) to notify the user.
In older STM32 families produced using well-matured 90nm technology (such as 'L4), FLASH is probably robust enough so that no FLASH faults occur within the normal operating envelope. It's the same technology node used in some non-ECC FLASH models (e.g. 'F4 and 'F7 - although it's low-power version), after all. That means, that users can ignore the ECC in such mcu in many applications.
However, if FLASH corruption results in a double-or-more-bit fault, reading from such faulty location will lead to NMI 1. And, if NMI is unhandled, default handler usually contains an infinite loop, which then leads to a surprising mcu "freeze". The NMI handler has to clear the flag indicating ECC error leading to NMI (usually FLASH_ECCR.ECCD) 2, otherwise the NMI handler would tail-chain into itself forever.
One way how such FLASH corruption may occur is in applications which use the FLASH to store configuration or status data, i.e. use it in an EEPROM fashion. If during erasing or writing to FLASH power failure occurs, the FLASH may remain in inconsistent, corrupted state, subsequently detected by ECC and leading to the NMI.