Before an IPO, a company is privately owned by founders and early investors. In the IPO it issues shares to the public for the first time, and afterwards those shares trade freely on an exchange like the NSE or BSE.
Companies do this to raise capital for growth and to give early backers a way to sell. Investors apply for shares at the offer price, often through the ASBA process in their bank or broker app.
For example, if a company offers shares at ₹500 and lists at ₹650, early allottees see a listing gain. But IPOs can also fall below the offer price, so they carry real risk and are never a guaranteed profit.