In order for a logical circuit to "remember" and retain its logical state even after the controlling input signal(s) have been removed, it is necessary for the circuit to include some form of feedback.
We might start with a pair of inverters, each having its input connected to the other's output.
The two outputs will always have opposite logic levels.
Click on this link for further information: http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/nandlatch.html
Enjoy...😎