Launching a torpedo from a moving plane against - a moving ship was an extremely difficult art that the Japanese excelled at. This was due to their complete mastery of torpedoing techniques, an excellent torpedo, and, for a while, a better torpedo plane (the American TBD Devastator was far less effective than the Japanese Kate, though the TBF-1 Avenger proved to be a successful replacement).
To launch a torpedo strike against a ship, a torpedo squadron would cruise at a high altitude and dive when a target was spotted. They would break out of their dive at an altitude of 100 feet or less above the ocean. Sometimes a torpedo squadron would split up to attack a target from different directions. If they flew together in formation, torpedo planes were easier targets for fighters and anti-aircraft fire, as were the American torpedo squadrons at the Battle of Midway.
Flying at a low altitude, a torpedo plane would approach a target. The preferred attack position was to be facing either the bow or stern of the ship, since any way the ship turned would leave it vulnerable to a hit. Ideal attack position was with one or more planes on either bow of target. A large vessel like a carrier cannot turn in a small circle, so whether she turn to port or starboard at least one hit might be expected. The ideal attack position was with one or more planes on either bow of target. A large vessel like a carrier cannot turn in a small circle, so whether she turn to port or starboard at least one hit might be expected. Having torpedo planes approach a ship from both sides of the bow was known as the Anvil Attack (smashing the target on the Anvil), but the coordination of timing required was difficult to achieve.
When the torpedo plane was within 1,000 yards or less of the target, the torpedo was released. A 45-knot torpedo launched 1000 yards away takes 40 seconds to reach target. In 40 seconds a ship traveling at 30 knots moves 2,000 feet.
A lot could go wrong with a torpedo once it was launched. Torpedoes are delicate mechanisms, and (especially when dropped from a plane) they did not always run straight and true. It had to land perfectly flat on the water to run true to the target. If it landed at a sharp angle, it would dive straight down; if it landed at a shallow angle, it would bounce up and down on the surface. Occasionally the torpedo would simply break up when it hit the water. If the torpedo did land perfectly, it was designed to dive, then rise to a pre-set depth just below the surface. If the depth mechanism was faulty, it could cause the torpedo to run too deep and end up going underneath the target. If it did reach the target their exploders might not trigger the bursting charge or explode it too soon. Sometimes, a slow-moving torpedo could be exploded by machine gun fire aimed at its warhead. On top of all this, the torpedo planes themselves were comparatively slow, and so were vulnerable to fighters and AA fire.
And even if all went well and the torpedo did hit the target, there was always the chance that it would be a dud and fail to explode. American torpedoes were notorious for this, to the point where it was an occasion to celebrate when one actually did detonate. But when a torpedo hit and exploded, it struck a highly-damaging blow to a ship in a vulnerable area - below the waterline. The ability to inflict such damage on a surface ship, no matter how great the odds of failure, made torpedo-bombing an important weapon in the Pacific war.