Why IgM is normally the first antibody to be produced during any infection?

A mature naive B cell expresses on its cell membrane as receptors IgM and IgD. When it finds a specific antigen, it will undergo several divisions and finally differentiation in memory cells and plasma cells. The genes that code for the IgM class are still present in the plasma cells, and therefore those are the types of antibodies that are first produced and released. However, later class switching occurs within those genes, and new types of antibodies with the same specificity are produced (IgG, IgE, IgA)