Even under the supervision of an experienced in-house lawyer and a group of well-qualified outside counsel, a multibillion-dollar startup’s plan to go public can still get derailed.

In one month, the co-working company WeWork went from getting ready for the public market to oustering its co-founder and chief executive Adam Neumann, and then indefinitely postponing its IPO.