In my (limited) experience, when you have something mechanical that works sometimes and doesn't work sometimes is likely to be caused by something interfering with that action. In the case of firearms moving parts, that interference is frequently caused by gunk.
A moving part that is not free to move can't do its job.