Upon entering the war, the German navy had relatively few submarines, with a total of 57, divided among six flotillas. These were Types I, II, VII and IX in Type A construction (the new Type VII B boat was under construction).
The Kriegsmarine realized that these boats had to be further developed. Thus, new models with improvements and modifications were created quite quickly. Which were used in the very lossy submarine warfare.
The Type XXI was not completed in time to have a decisive impact on the war effort.