Cardiff Garcia offers this chart from Birinyi Associates showing that one reason stock markets are touching record highs this month is that share buybacks reached a record high back in February.
Basically when a firm makes a profit it can do one of four things with it. One is give money to its shareholders by paying dividends. One is save the cash for a rainy day. One is go out and spend the money on some investments. Last is it can spend the money buying shares in itself, letting some shareholders cash out and leaving the remaining shareholders with a scarcer (and therefore more valuable) asset.
This dynamic is one reason that even though the stock market isn't the real economy, it can be relevant to the real economy. Most business investment is internally financed—option three above. In principle, as share prices rise, option four gets less attractive and option three therefore gets more attractive. That's the theory, at any rate. When stocks are cheap, firms buy shares. When stocks are expensive, they buy capital goods. We'll see if it happens in practice.