Your gun is ok as the slide lock back manually, so it's something in the shooting sequence... is it your first pistol or your first pistol shooting experience?
My guess...
1. Your gun may be dirty or greasy. Do you clean it fully before shooting?
-- Solution: Fully clean the slide and frame assembly to remove all grease and other.
2. Your gun is not well lubricated.
-- Solution: Fully degrease and clean, and put little oil on all part, and few drop in slide/frame rails.
3. Your ammo is too weak. Not enough pressure to work properly. Do you reload?
-- Solution: Try good factory ammunition, like WWB, AE, or similar.
4. Your stance is weak or sloppy, so your arm absorb most of recoil energy, and the slide miss some.
-- Solution: Fully extand your arms, and lock your elbow.
5. Your thumb touching the slide or slide release (even just a little), it's may be enough to slow the slide and not alloing the slide to lock.
-- Solution: Make sure to not touch the slide with any fingers.
Remember, the slide have to get fully to the back in order to lock on a emply mag. When firing, this movement is done on recoil energy, so any loss in this energy will slow the slide, and the slide may not be able to fully move to the back, even few thousand of an inch may be enough to not lock properly.
I'm pretty sure your gun an mags are OK as when you did it manually, you bring the slide fully to the back and it lock properly. So it have to be something happening during the recoil sequence slowing down your slide movement.