Stocks have roared higher over the past year, and much of that gain is thanks to the "Magnificent Seven." I'm not talking about the Western that hit the silver screen back in 1960 or a newer version that made it to theaters in 2016, though. The seven I'm talking about are a group of industry-leading companies, all developing cutting-edge technology, with names you'll probably recognize: Alphabet (GOOG 0.46%) (GOOGL 0.49%), Amazon, Apple (AAPL 1.61%), Meta Platforms, Microsoft, Nvidia, and Tesla.

All of these stocks, with the exception of Tesla, have climbed in the double or triple digits over the past year, helping the indexes rise in this new bull market. There are many reasons to like the Magnificent Seven, from their growth track records to their investments in hot technologies, like artificial intelligence (AI).

These players also stand out for their moats, or competitive advantages. A moat is particularly important because, if it's strong enough, it can help a company hold onto its leadership for the long haul -- and that can result in lasting earnings growth. Two Magnificent Seven stocks, in particular, offer rock-solid moats -- which is one of the reasons they should be on your buy list.

An investor in an office smiles while looking at something on a laptop.

Image source: Getty Images.

Alphabet

Alphabet is the company behind a tool you may use daily: the Google search engine. When most of us need to find out about something, our first reflex often is to "Google" it. Advertisers know this, and that's exactly why they flock to Alphabet to advertise their goods or services on Google. These advertising dollars make up the lion's share of the company's revenue -- 75% of it in the recent quarter -- and that's likely to continue, thanks to Alphabet's terrific moat.

The company's competitive advantage in search is that most of us turn to Google Search as part of our daily routine. And this has helped the platform steadily hold a more than 90% share of the search market. This dominance also has reinforced Alphabet's competitive advantage.

Alphabet's moat may be about to get even stronger because the company is investing in AI, a technology that can make search even better. The company introduced Gemini, its most powerful AI tool ever, late last year and recently launched the next-generation model -- Gemini Ultra.

Alphabet is testing Gemini in search, and the results have been very positive -- making the process faster -- and generative AI is improving search results in many ways. For example, Google can address more complex questions and offer a broader range of links corresponding to your query.

All of this should keep people coming back to Google for their search needs -- which means advertisers should stick around, too. On top of this, Alphabet has developed AI tools to help advertisers create their campaigns. Chief Executive Officer Sundar Pichai says the company has seen "a lot of interest" here.

Today, Alphabet shares trade for 20x forward earnings estimates. This is an absolute steal for a Magnificent Seven stock with such a fantastic moat.

Apple

Apple may be a word you pronounce every day in your household -- not referring to the fruit but, instead, to the company that makes so many leading consumer products from the iPhone to the Mac. Owners of Apple products tend to stick with them, regardless of price increases or the offerings or rivals. As a result, this technology giant has enormous brand strength.

This brand strength is Apple's moat, and so far, it's been rock solid over the long term. In the smartphone market, Apple has held a place among leaders, and last year, rose to the top of the rankings with the iPhone. For the first time ever, the company became the world's No. 1 player in the smartphone market, with a 20% market share, according to research firm IDC.

The total installed base of Apple's devices recently reached a new record high of 2.2 billion worldwide. Not only did the iPhone's active user base reach a record, but Apple announced an all-time high of iPhone upgraders during the quarter -- which shows that users keep returning to Apple.

But this doesn't mean Apple's growth is limited to current customers. The company also continues to attract new users to its products. For example, in the recent quarter, about half of Mac and iPad buyers were new to those particular products -- and two-thirds of Apple Watch customers were first-time buyers. Apple's brand strength helps it hold onto longtime customers and bring in new ones.

This strength has helped Apple increase earnings in the triple digits over the past decade -- and grow return on invested capital. That means Apple's investments have been wise ones, and the company has benefited from them.

AAPL Net Income (Annual) Chart

AAPL Net Income (Annual) data by YCharts.

Today, Apple shares trade for 27x forward earnings estimates. This is a very reasonable price for a company that's delivered so much growth over the long term -- and promises more to come, thanks to its rock-solid moat.