Spherical and nonspherical models of primordial black hole formation: exact solutions