Behind the age and gender prediction lies the work of the neural network or a "model" that was trained with the purpose of estimating age and gender. The model was trained by inserting large datasets with face images and metadata relevant to information about the age and gender of those faces.
Each time a subject walks in front of the camera after face detection and landmark detection was completed, age and gender prediction are performed independently since it uses the model trained specially for that purpose.