An ICO is just the act of pre-selling a new altcoin, before it reaches exchanges. This is a bit like crowfunding, this helps new companies here to get some revenues for marketing, paying employees, offices, taxes... Generally, buying during an ICO is more risky so the price per coin is lower than after it reaches an exchange (even if it's sometimes not true).
Not all altcoins are created from an ICO, this was mostly the 2017 trend. And even, not all coins from an altcoin issued from an ICO are dedicaced for the ICO, as you have bounties, parts given to the team or helpers which aren't sold during an ICO.