2017 has already been a good year for investors: The broader market, as represented by the S&P 500, is up 9% year to date and shows little sign of slowing. Over the longer term, the numbers are even more impressive, with the market up nearly 25% over the last three years and an astounding 86% over the last five years.

Yet even as the current bull market gets a little long in the tooth, investors are looking for stocks to invest in now. One strategy is to look for great companies with sustainable competitive advantages that maintain a dominant position in their respective industries. Even in the event of a market correction, companies like these will likely recover faster and grow more than their counterparts. So what are investors' best bets going forward?

Here are three companies that not only fit the above criteria, but are also investing in growth areas outside of their core competencies, which could provide significant future gains.

Businessman pointing to a growth chart showing business success

What stocks can investors still buy in 2017 for outsized gains? Image source: Getty Images.

E-commerce titan

When it comes to e-commerce, no company commands a more dominant position than Amazon.com, Inc. (AMZN 0.81%). This company started out as a humble online bookseller and has morphed into an online seller of just about everything. Amazon generated $136 billion in revenue last year, and 70% of that amount was the result of e-commerce sales. In the U.S., e-commerce represented just over 8% of retail sales and clocked in at $390 billion for 2016. That figure is expected to grow to over $485 billion by 2021, according to Statista.

Amazon made headlines earlier this month with its offer to purchase Whole Foods Market, Inc. (WFM) for a whopping $13.7 billion, which would jump-start its aspirations in the grocery industry. The company has also been making bold moves in apparel, announcing Prime Wardrobe, which gives shoppers seven days to try on clothes, and provides a return shipping label for unwanted items. It even offers discounts if customers keep the majority of items.

Amazon's biggest competitive advantage is Prime, which costs members $99 per year for free two-day shipping and gives them access to a host of other services including the Prime Video streaming service. Amazon currently sports 80 million members in the U.S., according to Consumer Intelligence Research Partners, and those members spend nearly twice as much as nonmembers.

Buying Amazon gives you an investment not only in e-commerce, but also in the growing areas of cloud computing and artificial intelligence (AI).

AMZN Chart

AMZN price data by YCharts.

Massive social network

Facebook, Inc. (META 2.33%) is the undisputed king of social networks, owning the three most popular platforms worldwide. As of March 2017, Facebook had 1.9 billion monthly active users, while WhatsApp and Messenger each claimed another 1.2 billion each. With that type of reach, it would be difficult for any competitor to gain significant traction because of the massive network effect. And Facebook has been adding additional features like video to keep members engaged.

The company generated a massive $8 billion in revenue in its most recent quarter, growing 51% year over year. With the increasing prominence of WhatsApp and Messenger, Facebook will likely be able to continue growing its advertising for the foreseeable future.

Facebook has also been conducting a significant amount of research into the area of artificial intelligence, which can help recognize your friends in photos and suggest people you might know; lately it has been using AI to fight terrorism.

Search is only the beginning

Alphabet Inc. (GOOGL 0.37%) (GOOG 0.32%) is known primarily for its ubiquitous Google search engine, and that alone would be enough to command an investor's attention. The company generated over $24 billion in its most recent quarter, a 22% increase over the prior-year quarter. Net income jumped 29% to $5.4 billion.

The most intriguing thing about the company is not where it has been, but where it's going. Google was one of the early players in artificial intelligence (AI), and it has parlayed that research into a number of groundbreaking technologies. The company recently spun off its self-driving car technology into a division called Waymo, from its previous home among Alphabet's other moonshot projects. With the most technologically advanced autonomous driving program, the company could be the first to reap the rewards in an area that could change the way the world travels.

Google has already deployed its AI in a number of ways that indicate its future potential. It created a system that beat the best player in the world at the ancient and complex game of Go, developed a groundbreaking chip for training AI systems, and bested human pathologists at detecting cancer in medical images.