The statistician in me says that the U.S. stock market will be markedly higher five years from now. Based on around 100 years of data, that's what the odds point to. Depending on who you ask, the average bear market -- a stock market decline of 20% or more -- lasts between nine and 12 months. And we're roughly in that range now.

By contrast, the average bull market lasts for years, and the next one could potentially carry us to the five-year mark, which is why I'd be willing to bet the market will be higher at that time. Therefore, it won't be easy for stocks to beat the market over the next half-decade -- it never is. But PubMatic (PUBM 3.02%) and Block (SQ 5.04%) are two companies I believe could get the job done.

PubMatic: How it's gaining market share

There are only a few public digital-advertising companies, including demand-side platforms like The Trade Desk and supply-side platforms like PubMatic. But make no mistake: There are scores of privately held players on both sides of the business, and they're all vying for the same customers. The space is far more competitive than investors might think, and market share is important.

One way PubMatic is growing is through supply path optimization. Brands and publishers tend to work with dozens of adtech companies at the same time. And working with scores of ad companies can decrease an ad campaign's effectiveness by lowering its targeting capabilities. Therefore, publishers look to PubMatic to improve their ads' performance with supply path optimization. 

By way of example, PubMatic expanded its supply path optimization deal with advertising and communications company Havas Media Group on Aug. 17. Later at the Evercore ISI Technology Conference, management said that expansion deals like these often take companies like Havas from around 10 supply-side platforms to just two or three, of which PubMatic is the preferred provider. This helps the company gain market share.

According to management, 24% of all activity on PubMatic's platform in the second quarter of last year was from supply path optimization deals. As of 2022's second quarter, that's up to 30%. And management loves how this strengthens customer retention. Also at the Evercore conference, management said, "There's really no reason why we would get thrown out of a [supply path optimization] deal...unless we really screw something up." As a shareholder, I like this dynamic.

The importance of this methodology for cutting redundancies out of the path between ad buyers and ad sellers  is why PubMatic acquired a company called Martin in September. Terms weren't disclosed beyond the fact that PubMatic is paying cash. But it's buying Martin to make its supply path optimization services more compelling.

With interest rates rising and economies worldwide slowing, macroeconomic conditions favor the strongest players like PubMatic and hinder the rest. I'll stop short of predicting every facet of PubMatic's business over the next five years. But the company is profitable and has a $183 million cash position, both of which will help insulate it from the struggles many smaller competitors will likely face in a downturn.

There are many more reasons to like PubMatic stock long term. But as smaller players get weeded out due to the economy and by clients optimizing their advertising supply, I believe PubMatic will generate market-beating results.

Block: Global expansion is revving up

Through the first half of 2022, revenue for financial technology (fintech) company Block has fallen by 14% from the comparable period of 2021. However, its revenue from international markets rose a whopping 132%, showing the importance of its global expansion.

Take that growth rate with a small grain of salt, because not all of Block's international revenue growth was organic. In February, it completed its acquisition of Australia-based "buy now, pay later" company Afterpay. That added $208 million to its top line in the second quarter of 2022 alone, and some of this revenue came from international markets. For perspective, Block only had $257 million in total international revenue in Q2. Therefore, its 132% jump so far in 2022 has a lot to do with Afterpay.

That said, Block's management believes organic revenue growth in international markets will be accelerated because of Afterpay. The company is basically trying to build its Cash App ecosystem -- what it calls a "social money network" -- so that it doesn't matter where users are in the world or what currency they are using (including cryptocurrency), they'll be able to send funds back and forth without friction. And it believes Afterpay will propel it toward this dream.

Block offers different Cash App services and products in different markets, of which buy now, pay later is one. As it backfills existing markets with additional products, management believes it will see strong adoption due to network effects. In other words, people will want to use Cash App more and more because of how comprehensive it is and how many other people are already using it.

Excluding revenue generated from Bitcoin, Cash App has generated nearly $1.6 billion in revenue in the first half of 2022 -- about 19% of Block's total revenue. Bitcoin revenue is 42% of total revenue on its own and is inside the Cash App ecosystem. But I exclude it because it's not intended to generate any profits -- it's just a service Block provides. But in contrast to Bitcoin, Cash App is very profitable, generating around $1.3 billion in gross profit so far this year -- 48% of Block's total gross profit. 

In other words, Cash App is a relatively small revenue stream for Block, but it accounts for around half of the gross profit. This is why I'm excited to see it expand globally. If it's adopted by the masses as management hopes, profits could soar and turn Block stock into a market-beater.

To reiterate, it won't be easy to beat the market over the next five years because the market is likely to perform well. However, I believe PubMatic stock and Block stock have what it takes and are worth buying today.