There's a lot of human ingenuity applied in deciding when and how to blow things up. Munition can be timed, or use some sort of proximity sensing, etc.
Even artillery grenades, hurled out in great numbers, have such technology (and have had since WWII); for a nuclear torpedo, even a radar-operated fuze or at least a magnetic sensor would make sense.
While there isn't much public information about the Type 53-58 (the Soviet torpedo in question), it was probably a straight-runner with a range of 11nm - 13nm. It was also intended for area effect, not direct impact. Considering these parameters, it was probably fused to trigger the warhead at the end of its run, i.e. when the engine ran out of fuel. It may have had a timer or "run to detonation" feature instead, but as I said public information is scant.
Yes, nm is a common abbreviation for nautical miles in cases where they're used. And thankfully it is unusual to encounter a situation where you can't tell which one was intended.