In general, you don't. The buyers of an IPO are usually large institutional investors who have been courted directly by the company and the banks managing the IPO. You can of course try to get in on the first public trades on IPO day, but you won't get the IPO price (unless things go very wrong for the company).
Direct listings have been getting a little more popular; in a direct listing a company just puts their stock up for sale on an exchange without going through the IPO process, and it just starts trading at whatever the market thinks is fair. But it's still fairly rare to see a direct listing.