In Intel® MAX® 10 devices, the security key is part of the Initilization Configuration Bits (ICB) settings stored in the internal flash. Due to the lack of flow control syntax in Serial Vector Format (.svf), the Intel® Quartus® Prime software generated .svf file always has a "MAX 10 DSM Clear" operation that erases all ICB settings in the internal memory.
So the security key is erased every time when an Intel Quartus Prime software generated .svf file is used for programming.
To work around this problem, remove the following lines in the .svf file:
!
!Max 10 DSM Clear
!
SIR 10 TDI (203);
RUNTEST 128 TCK;
SDR 23 TDI (000000);
SIR 10 TDI (3F2);
RUNTEST 8750003 TCK;
!