The number of shares can increase for several reasons; the company issues more shares to gain more money to invest; the company splits existing shares so that the price per share drops and you don't get silly figures for one share. Do this a few times and the total number of shares can go up quite a bit.
If you are buying shares at $300 a share, you are expecting a return of at least $15 a share per annum; one way of obtaining this is if the share price goes up - in the same way as people expect the value of their houses to rise. The other is that Apple can afford to give you $15 a share every year.
The more Apple can give you per share each year, the more people are prepared to buy the shares to get the return; so the price goes up. The problems come when Apple hits the buffers and can no longer offer that rate of return.