Follow the money. There's a lot of investing wisdom packed into those three words. Companies that generate huge profits and cash tend to have stocks that perform exceptionally well for investors over the long term.

We can look at some of the biggest winners of this year to find great examples. Here are three stocks to buy for 2024 that are practically money machines.

1. Alphabet

Alphabet (GOOG 9.96%) (GOOGL 10.22%) gave shareholders a lot to be merry about this holiday season. The stock is on pace to finish 2023 with a huge gain of close to 60%.

Is Alphabet a money machine? The numbers speak for themselves.

The tech giant generated nearly $67 billion of profits and levered free cash flow of nearly $71 billion over the 12 months ending Sept. 30, 2023. Alphabet's earnings jumped over 41% year over year in the third quarter. The company sits atop a cash stockpile of almost $120 billion.

Two core businesses made those impressive results possible. Alphabet makes most of its money from advertising on Google Search and YouTube. Its Google Cloud unit is also a key growth driver.

I look for both of these businesses to fire on all cylinders in 2024. An improving economy could boost advertising revenue. Alphabet's launch of Gemini Ultra, a worthy rival to OpenAI's GPT-4, should help Google Cloud accelerate its growth.

2. Amazon

Amazon (AMZN 3.43%) has been sizzling hot in 2023. Shares of the e-commerce and cloud services leader have skyrocketed more than 80%. Amazon is on course to post its best performance since 2015.

The company generated earnings of $20 billion and levered free cash flow of more than $36 billion over the trailing-12-month period ending Sept. 30, 2023. Management has focused intently on its bottom line, and it shows. Profits more than tripled year over year in Q3. Amazon's cash position, including cash, cash equivalents, and short-term investments, currently tops $64 billion.

Even though Amazon dominates the e-commerce market, there's still plenty of room for growth. In Q3, e-commerce accounted for 15.6% of total U.S. retail sales. The company is also expanding into new online markets, recently announcing plans to begin selling cars online in 2024.

I think there's an even greater growth opportunity for Amazon Web Services (AWS). Between 5% and 10% of global IT spending is in the cloud right now, with the bulk of spending on-premises. This should flip over the next 10 to 15 years. As the market leader in cloud services, AWS is poised to benefit significantly from this growth.

3. Microsoft

Microsoft (MSFT 1.82%) ranks as the second-largest company in the world, based on market cap. However, this gargantuan size doesn't seem to be hindering its growth. The company's shares have soared more than 55% this year.

Unsurprisingly, Microsoft is a cash cow. It generated net income of $77 billion and levered free cash flow of $50 billion over the 12 months ending Sept. 30, 2023. The company's profits jumped 27% year over year in Q3, and Microsoft's cash stockpile totals nearly $144 billion.

Generative AI (artificial intelligence) continues to provide a huge catalyst for the company. The tech giant owns 49% of ChatGPT creator OpenAI's for-profit operating company. Microsoft has integrated GPT-4 throughout its products. This has made the company's Azure cloud platform especially attractive to customers.

Perhaps the most appealing thing about Microsoft is that it's a leader in nearly every hot new technology. AI and cloud services are definitely on the list. So are gaming, quantum computing, and virtual reality. I expect that Microsoft will remain a big winner for investors for a long time to come.