The full answer to this question is massive. Historians have written books inn the subject and still not covered everything.
To give you a brief explanation, the Allied strategy in the Battle of the Atlantic had four prongs: intelligence, the convoy system, air cover, and hunter-killer groups.
A major source of intelligence was "Ultra," decryptions of encoded and enciphered messages sent by German land-based HQs and by individual submarines at sea. In May 1941, the British were able to capture a German trawler and the U-Boat U-110. This gave the British information on naval code settings, an intact Enigma cipher machine and its settings (the key to deciphering Enigma messages), as well as materials for a secondary cipher system. For 5 months, the British were able to "read the German's mail." Although the messages were several days old by the time they could be deciphered, they were still very valuable. Allied commanders could route convoys around German U-boats.
In February 1942, the Germans a new rotor was added to their naval Enigma machines, making their ciphers much harder to break. Allied codebreakers were largely stumped until October 1942, when British destroyer HMS Petard captured the code books of U-559. Two of Petard's men died to get the books, trapped when the submarine suddenly sank as they searched it. In June 1944, Captain Daniel Gallery became the first American to bag German secrets. U-505 was captured, along with it's Enigma machine and codes. In order to keep the secret of its capture from leaking out, the surviving Germans were kept isolated from the Red Cross and other POWs.
The second, even more important source of intelligence was High Frequency Direction Finding, also known as HF/DF or "huff duff." Land-based (and eventually ship-based) radio receivers were used to to triangulate radio emissions from German U-Boats. German shore commanders heavily micromanaged their U-Boats at sea and demanded a steady stream of information. This gave the British plenty of chances to locate U-boats. These could be avoided, or hunted down.
The convoy system used in WWII was a further refinement of the system the British used on a large scale in 1917-1918. Convoy escorts patrolled around a large group of transport ships, tankers, and other merchantmen. Initially these escorts were destroyers, but as time went on, navies developed more specialised escorts like the US Navy's destroyer escorts and the Royal Navy's sloops and frigates. These vessels were smaller and cheaper than destroyers, so they could be made in far greater numbers.
These escorts made use of a variety of specialised sensors and weapons. Underwater microphones known as hyrdophones (passive sonar) and British-developed Asdic (active sonar), enabled sub-hunters to find submerged U-boats. Radar could find surfaced U-boats. This foiled a preferred tactic of U-boat wolfpacks early in the war. A large group of submarines (usually 2-5) would exploit their superior speed (17 knots, compared to 10-12 knots for the convoy) to attack the convoy from multiple directions on the surface at night. With radar, Allied escorts could spot surfaced submarines and stop them.
Escorts also had specialised weapons for hunting U-boats like depth charges and the Hedgehog and Squid mortars. These latter weapons fired mortar bombs at a point in the water. If a Hedgehog mortar hit a U-boat, it would explode. Initially developed by the Royal Navy, Hedgehog was later fitted to US Navy, US Coast Guard, and Royal Canadian Navy escorts.
Interestingly enough, the United States' involvement in WWII predates Pearl Harbor. From August 1941, the US Navy escorted convoys all the way out to Iceland. One destroyer, the Kearny, was torpedoed and badly damaged. Another, the Reuben James, was sunk with the loss of 100 men. In September 1940, the US also gave the British 50 old destroyers as part of the Destroyers for Bases agreement.
The third Allied asset was airpower. US Navy patrol aircraft and aircraft from RAF Coastal Command scoured the waters of the North Atlantic. If these aircraft spotted a U-Boat, they would dive and attack the surfaced U-Boat with rockets, bombs, or depth charges. The diesel-powered German U-Boats had to surface to recharge their batteries, so they were critically vulnerable to air attack while on the surface. Innovations like aerial radar and the Leigh Light (which paired radar with a powerful searchlight to illuminate U-Boats for night air attack) made aircraft even more dangerous predators. By 1944 and 1945, German U-Boats were forced to use a snorkel to recharge their batteries while still underwater. However, snorkels and periscopes could be seen by late-war Allied radar, so this was hardly a guarantee of safety.
Initially, the mid-Atlantic could not be reached by medium-ranged aircraft like the British Short Sunderland or the American PBY Catalina. This gave U-Boats an area (the "Mid-Atlantic Gap") where they could operate without fear of air attacks. By 1943-1944, the introduction of very long-ranged American-made Consolidated Liberator, enabled the US Navy and RAF to close this gap.
Convoys also brought along their own air cover. The Battle of the Atlantic was an air battle as well as a sea battle. German bombers attacked convoys and the notorious FW 200 Condor was used to sniff out convoys for the U-Boat wolfpacks to kill. As a stopgap, some merchantmen were fitted as CAM (catapult aircraft merchant ship). They could fire an obsolete Hurricane fighter off the end of the ship. The fighter could then shoot down the intruding Condor. Without anywhere to land, the pilot had to ditch and take his chances. CAM Hurricanes shot down nine German planes for the loss of just one pilot. Pilot Officer J.B. Kendall died after bailing out.
Eventually, a better solution was devised. Merchant ships were converted into small escort carriers with proper flight decks. These escort carriers could provide air defense for the convoys and send out planes to hunt U-Boats.
Escort carriers formed the nucleus of the Royal Navy and US Navy's hunter-killer groups. These groups consisted of 1-2 escort carriers and several surface escorts. Carrier planes would locate and attack U-Boats. Then, the surface warships could close in and finish off the submarine. Since they didn't have to worry about escorting a convoy, hunter-killer groups could be relentless in their pursuit of submarines and see the hunt through to the finish.
As for the Royal Canadian Navy contribution, the RCN's main mission during the war was escort work. By war's end, the RCN had 270 ocean escort warships, making it the third-largest navy in the world after the United States and Britain. Canadian ships sank or helped sink 31 German submarines.