The firm going public hires an investment bank, or banks, to handle the IPO. It's possible for a company to sell shares on its own but, in reality, that never happens.
Investment banks can work alone or together on one IPO, with one taking the lead. They usually form a group of banks or investors to spread around the funding — and the risk — for the IPO.
Banks submit bids to companies going public on how much money the firm will make in the IPO and what the bank will walk away with. The process of an investment bank handling an IPO is called underwriting.
When an investment bank, like Goldman Sachs or Morgan Stanley is eventually hired, the company and the investment bank talk about how much money they think they will raise from the IPO, the type of securities to be issued, and all the details in the underwriting agreement.