Why do square pyramidal molecules have only two vertical mirror planes?
Either your book is wrong or you are misunderstanding what it is trying to say.

There are 4 vertical planes of symmetry.

See for example GROUP THEORY AND ITS APPLICATIONS IN CHEMISTRY, SECOND EDITION , section 1.5.2

See especially:


  Vertical planes are further classified into two, namely $\sigma _v$ and $\sigma _d$ The $\sigma _v$ planes fall along the bonds and the $\sigma _d$ planes bisect the bond angles in molecules. The subscripts v and d stand for vertical and diagonal. However, both $\sigma _v$ and $\sigma _d$ are vertical planes