Specifically with regards to technology and tactics, I'd love to hear what advances different countries made in submarine warfare and perhaps anti-submarine warfare.
At the beginning of WW1, there was no target-oriented doctrine of operation. Both sides mainly used them for patrolling in enemy-controlled areas, and to fight hostile combat vessels. The German admiralty, however, quickly came to realize that submarines could be effectively used as Handelsstörer, or commerce raiders. Despite efforts made by the United Kingdom, among them the deployment of the so-called Q-ships (heavily armed merchant ships with concealed weaponry and sometimes even neutral display of flags, which were designed to lure submarines into surface combat where the Q-ships could effectively attack them), ship losses continuously rose. This didn't change until September 1917, when the British Admiralty officially introduced a convoy system. Because of the convoy, submarines weren't able to make surface attacks, and were forced to attack underwater, which had a very slim chance of success because of slow underwater speeds, and it only succeeded when the course of the convoy was convenient for an attack. The main weapons deployed by submarines in WW1 were deck guns. Torpedoes were only used in surprise attacks, when the submarine stayed underwater. German submarines also laid thousands of mines, which proved to be especially effective in the English Channel.
In WW2, the biggest initial change in comparison to the First World War was the newly available radio technology, along with the new tactics this enabled – mainly the Rudeltaktik, or wolfpack tactic, whose foundational concept was to attack a large convoy with an equally concentrated "pack" of U-boats. Movement was centrally controlled by the Befehlshaber der U-Boote, BdU, or Commander of Submarines, while submarines patrolled likely convoy routes individually. Once an enemy convoy was located, the spotting submarine alerted the BdU, who relocated several submarines from around the area to the scene of the convoy. Once a sufficient number of U-boats (compared to the expected threat of the convoy) gathered, the BdU gave clearance for an attack. While the Rudeltaktik proved to be a serious threat to Allied ships, it also had some blatant weaknesses – namely the heavy reliance on radio communication to organize the attacks, which was effectively met with countermeasures: High-frequency direction finding, abbrev. HF/DF and commonly referred to as huff-duff, allowed Allied naval forces to determine the location of the transmitting U-boats and attack them. Furthermore, air cover offered by blimps, planes with radar and escort carriers allowed submarines to be spotted as they waited to attack convoys. The US later adopted the wolfpack tactic, although without central coordination. Submarines proved to be effective weapons on all naval theaters. Both US Navy and Kriegsmarine mainly deployed submarines in economic warfare, to disrupt enemy logistic. After the US entered the war, German U-boat leadership changed the focus from blocking the UK to a strategy to sink more hold than the enemy could produce (Tonnagekrieg). This made deployment sites secondary, and German U-boats were fighting in all seas, only restricted through technical and supply limits. Due to allied technological advancement, like radar, HF/DF and the deciphering of the Enigma-decyphering, and material superiority with simultaneous overextension of Axis' resources, the German U-boat war was historically lost by May 1943. There was still some technological advancement, which came too late to influence the war, but still led to strategic changes in warfare.
When it comes to the Pacific theatre, Japanese submarines didn't play a large role. They were varied, but not modern, as they had an emphasis on surface vessels. Their main deployment was against battleships, their sinking rates thus very low.
The US Navy, applying the wolfpack tactic, was far more successful and sunk major battleships and disrupted Japanese merchant shipping. The latter significantly contributed to the Allied victory in the Pacific, by cutting off Japanese supplies and resources, 2% of US-American marine personnel were responsible for destroying 55% of Imperial Japan's total tonnage.
However, the casualty rate for submariners is the highest of all US military service branches with 22%.
So all in all, the biggest differences between the First and Second World War were given thanks to technological advancement. The main doctrine was economic warfare, which remained consistent until the late phase of Atlantic U-boat warfare, and unchanged for the Pacific theatre.
Sources: Paul G. Halpern: A Naval History Of World War I, 1995 Clay Blair: Hitler's U-Boat War: The Hunters, 1939–1942, 1996 Clay Blair: Hitler's U-Boat War: The Hunted, 1942–1945, 1998 Clay Blair: Silent Victory. The U.S. Submarine War Against Japan, 1975
/u/im-self-employed has outlined some good basics, but there are a couple of caveats:
Modern submarine warfare and doctrine is traditionally attributed to the German Navy in the First World War, but the origin of the modern submarine force was in fact the Royal Navy under First Lord Fisher who had invested in the first modern flotilla or diesel/gas-electric submarines. This dual power plant - a diesel engine for surface cruises and an electric engine for running submerged - would become the primary means of powering submarines until the nuclear era. Germany was in fact simply building submarines because the British had them.
Moreover the idea that submarines were seen as ideal commerce-raiders from the outset is a myth. Despite its very bloody nature, all warring parties in 1914 in fact largely adhered to various international treaties regulating the rules of war. In terms of commerce-raiding, in particular, the Hague rules laid out that a merchant ship could only be destroyed once it had been inspected, found to be carrying war material, and the crew had been given time to evacuate. And even the destruction of the merchant ship was itself supposed to be a last resort, with the preference being to intern the ship instead.
Submarines, having tiny crews, were thus deemed completely unsuitable for commerce-raiding because they did not have enough men to inspect and intern enemy merchant ships. Their only option was to sink the enemy merchant ship outright, and given that the merchant ships were often larger than the U-boats it was not out of the question for the merchant to try and ram / sink the U-boat trying to inspect them! The British further exacerbated matters by deploying the aforementioned Q-ships. The light cruiser, which was big enough both in crew and size to intimidate and capture merchant ships, was in fact seen as the ideal commerce-raider based on 1914 doctrine.
Early German submarine doctrine thus focused almost entirely on attacking British battle fleet elements, and they proved to be rather successful in this role in 1914. While no British dreadnought was sunk to submarines (the Royal Navy's ultimate nightmare given their slim lead in capital ships), the U-boats sank a number of cruisers and forced the British to withdraw their battlefleet to the remote anchorage at Scapa Flow. There, with anti-submarine warfare still in its infancy, the British were forced to resort to preposterous "anti-submarine picket boats" whose only "armament" was a mallet for smashing submarine periscopes. On at least two occassions false periscope sightings caused the Grand Fleet to scamper out of its anchorage and remain at sea.
This changed however by 1915, due to the (technically illegal) British blockade of Germany. The British, with their larger surface navy, were able to easily capture German merchant ships while they hunted down all of Germany's stray light cruisers and merchant raiders. The Germans, with most of their surface raiding forces destroyed, were thus forced to switch to using submarines to target British merchant shipping. Initially, the Hague rules were adhered to; but it quickly became apparent that much better results could be achieved by unrestricted submarine warfare wherein merchant ships could be attacked without warning.
The 1915 campaign was thus the first real "unrestricted" submarine campaign in history. It was very successful from a material perspective, but it also provoked a massive international outcry particularly after the sinking of the liner Lusitania. America threatened to join the war after further sinkings that killed American citizens, which resulted in the suspension of the campaign.
That said, the Germans had now gained valuable experience in how to properly use their submarine force as commerce-raiders. New boats were built in preparation for a future campaign, which began in February 1917. This pretty much caught the British off-guard and unprepared, resulting in an enormous number of sunk merchant ships and Britain coming very close to economic collapse. By the end of the war more than 4,000 merchant ships would be lost to the U-boats - greater than the number lost in the Second World War.
Britain however was saved in large part because the resumption of unrestricted submarine warfare brought the United States into the war as an ally. In addition, it was finally recognized that the antidote to the U-boat menace was in fact the age-old institution known as the convoy. Back in the age of sail, merchant ships had been grouped "convoys" - which were large formations that were escorted by a few warships to ward off pirates and privateers. This was initially deemed unfeasible by the British Admiralty because they had grossly miscalculated the amount of shipping that needed to be convoyed, estimating that they had to protect several thousand ships. However, it was eventually realized that the key ships supplying the war effort only amounted to around 250 ships weekly - the large ocean-going steamers which plied the Atlantic trade route - and that the rest (fishing boats, coastal steamers, and surviving sailing ships) could in fact be effectively left unprotected and sacrificed if needed.
As a result of these new convoys, U-boat sinkings of the key war-critical merchant ships dropped to almost nothing. U-boats of the era were simply too slow to make consistent underwater attacks against convoys guarded by warships. They continued to sink merchant ships - primarily by deck gun attacks rather than using torpedoes - but many of their victims were neutral shipping un-involved in the British war effort or "expendable" ships like the old sailing ships that were living as low-cost coastal freight ships.
That said, experiments in trying to "break" the convoys were conducted by individual U-boat skippers. One of them was Doenitz, who would later go on to lead the German Navy in the Second World War. His development of the wolfpack was in fact based on his experiments in the First World War.
===
As for the Second World War, /u/im-self-employed has it mostly right with regards to the Atlantic; albeit I will note that the U-boat "wonder weapons" were all overhyped. The Type XXI submarine, often claimed to be the forerunner of modern submarines, was in fact a catastrophically rushed mess. The first of these boats were in fact "completed" in 1943, but the first war cruise only happened in 1945 - on the day Hitler shot himself - because the boats leaked so badly that most could submerge only exactly once.
The real revolution in technology happened in the Pacific. The US submarine campaign is often considered to be a lesser version of the Battle of the Atlantic, against a Japanese Navy that was supposedly incompetent in anti-submarine warfare. However, most of these assessments are made by British veterans of the Battle of the Atlantic, who were largely unaware of how the Pacific was a very different submarine war.
For one thing, the Japanese merchant fleet was in fact very modern. Most of their ships could reach 15 knots in speed and could easily outrun even U-boats on the surface (British convoys average less than 10 knots in comparison). Moreover Japanese merchant ships had plenty of harbors to choose from to seek shelter in. It would have been very difficult for the German U-boats to have waged a commerce-raiding campaign against the Japanese had they been put in the US Navy's position.
That the US Navy's submarines performed so effectively - they sank something like 90% of Japan's pre-war shipping and accounted for 1/3 of Japanese warships - owed to their superior technology and doctrinal developments. In particular, US submarines were light years ahead of the U-boats because most of their boats had radar.
Radar allowed US submarines to find and hunt down enemy convoys and fleet units from beyond visual range. This allowed them to remain on the surface - travelling at full speed to keep up with the enemy - before submerging right before the actual attack (which was usually conducted at night). US submarines could thus create their own ambush situations; which was happening with an alarming degree of regularity by 1944.
HIJMS Kongo for instance was detected on radar by Sea Lion, which setup an ambush for the Japanese battleship and scored several hits. Kongo initially survived and tried to flee, but Sea Lion literally chased after her (just outside of visual range thanks to radar) until Kongo finally capsized and blew up. Even more remarkably, the Sea Lion's skipper then went after the other battleship travelling with Kongo - the Yamato herself - and did not stop until daylight and the possibility of air attack finally caused Sea Lion to break off! And this is just one of many engagements where US submarines used radar to run circles around the Japanese fleet - indeed by the end of the war more Japanese destroyers had been lost to American submarines than the reverse!
Now, it's worth noting that the Japanese had inferior ASW technology, but in the case of the Kongo they were in fact aware of the Sea Lion's presence due to radar detection equipment and the destroyers had done fairly effective depth-charge attacks based on sonar returns. They just were not prepared to fight blind against an enemy that had radar, and indeed the idea of putting radar on a submarine was deemed so unthinkable that Doenitz had previously declared that it was impossible to mount radar on a submarine prior to 1943! The Pacific submarine campaign was in fact a demonstration of how having superior detection range - thanks to radar - was much more important than any theoretical technical superiority in weapons or other boat statistics.