One must remember it's not the top speed that matters, but the cruise speed. That speed which maximizes range per fuel use. Many of the Atlantic convoys were limited to 10-12 knot cruise speeds, which are significantly slowed by zig-zag*.
Hardest part for an attacking submarine is calculating the best course and speed away from detection from a given convoy, so that the submarine could then surface and use it's best speed to an intercept point. (Even better was to have a code intercept that could simply place a submarine in the known path of a convoy, where it could wait, doggo, until the targets presented them selves.
LIners, like Queen Mary were designed to cruise at high speed--shaving a day or two off a transatlantic passage would pay for itself in passage fares. A sub with a top speed around 18-19kt could not maneuver enough to catch 18-22kt liners, unless they were very lucky (and the liner stayed at cruise speed only--trips to/from Blighty could be achieved without emptying the fuel bunkers at near top speeds, 25-28kts).
With more modern subs, which are faster underwater than surfaced, change the calculus.
________________________________________________________
*Zig-zags are not simple routines, even if submariners discount their utility. The zigs & zags were planned out in advance, and published as a set of offsets from base course. So, a plan might be to run xxx miles at nn speed at dd ±Base Course. The next leg would be at some other angle, at a different speed, and distance, and so on. This could be 11nm at 09kt at BC -55º, with the next leg 21nm at 11kts at BC+20, then followed by a leg of 2nm at 10kts and BC-25º.
This makes for a certain randomness. Even better plans allow variances too--which can be delivered in plain speech--"Mike Corpen ALFA DIST 01 COURSE NEG 02 SPEED 0" which will not mean anything unless one knows that means Zigzag plan A, change distance plus 1; angle -12º; no change in speed.
However, with a long enough observation radius and duration can be sorted out. The three-dimensional calculus of torpedo aiming was second nature to submariners, which meant they could visualize the target course with some chart paper and a slide rule. That the target convoys could be 20, 30, even 40 ships makes for a sizable thing to spot on the ocean, what with spacing from 3 to 5 miles between convoy ships.