A common cause of strings going flat, is tuning down to pitch instead of up.

Tuners often have backlash, due to clearance between the tuner gear teeth,
or other excessive free movement in the parts. The presence of backlash means
that the tuning key does not maintain complete control of the tuning post when
changing direction from tuning up to tuning down.

Tuning up to pitch eliminates the effects of backlash. When you turn the key
to increase pitch, all of the backlash will first be taken up before the post
begins to turn. Then as long as the key doesn't move, the key (and gears) will
maintain positive support for the post.

When tuning down to pitch, friction will often prevent the post from immediately
following the key downward. The backlash will have to be taken up in the other
direction before the post begins to move. These leaves the clearance between the
gear teeth on the "wrong side". The key is no longer supporting the post. Friction
is supporting it. Sometime later, the post will slip and take up the backlash.
The string goes flat.

.