Working as intended. As a crude form of balance, submarine torpedoes, can "fail", i.e. pass beneath the ship, as you said. That's called a "dud" and actually happened a lot to real submariners in WWII.
I really don't know all the criteria, but off the back of my head, some nations intrinsically experience more duds than others; for example, IJN has a lot of them, probably in order to balance out those hard-hitting fish.
And if I am not mistaken, higher-level Torpedomen remedy this problem a little, too.