I'm nowhere near the best combat player in the game, and I don't line up on target and then fire with my railguns either - I start the firing sequence, then finish lining up, then if I'm on target by the end of the sequence I fire and if I'm not I try to release the fire key before the end of the sequence and save the ammo. Entirely fair for the NPCs to do the same, but from the outside you don't see the shots they give up on firing.In terms of rails, they don't seem to require the same time on target before firing that we do. They just line up and fire - and never miss.
They did tweak the AI a while back so that it does sometimes miss with rails regardless (as opposed to what it was where it would reliably cancel firing if it was off-target so you never saw it miss, it just didn't fire), but it probably depends what you're flying - they miss my Krait quite a bit, but I wouldn't expect them to miss an Anaconda much because I don't miss Anacondas with rails much either...