The genesis of Stanford’s back-to-back national soccer titles might be traced to the late 1980s, when an English prep player mistakenly thought the city of Bakersfield was near the beach.

Simon Tobin, then the head coach at Cal State Bakersfield, was trying to recruit Jeremy Gunn, a striker for the local club team, on a cold, rainy day near his hometown of Grimsby, England.

Tobin, now head coach at San Jose State, laughed as he recalled telling Gunn, Stanford’s current head coach, that Bakersfield was “pretty close to the beach.”

“Luckily, in those days, we didn’t have the Internet,” Tobin said. “I still tell him he should have done a little bit more research.”

That little fabrication helped lead Gunn to a playing career at Bakersfield and a coaching career that has amassed a series of national championships. As an assistant coach, he helped the Roadrunners to the 1997 NCAA Division II title. He became head coach at Fort Lewis College in Durango, Colo., and his team won the 2005 Division II national title.

He then built UNC Charlotte into a national title contender. The 49ers reached the 2011 College Cup final before losing to top-ranked North Carolina.

Fresh off that achievement, he arrived in 2012 at Stanford, a school that traces its men’s soccer history to 1911. In more than a century, it had not won a national title. It had won a total of one Pac-10 or Pac-12 title, in 2001.

Those droughts ended under Gunn. With national titles in 2015 and 2016, he became the seventh Division I coach to win consecutive national championships. Led by Foster Langsdorf, the Pac-12’s leading scorer (10 goals, 23 points) and Nico Corti, its leading goalkeeper (0.53 goals-against average), the Cardinal (12-2-1, 6-0-1) are closing in on their fourth straight Pac-12 title. A win over visiting UCLA (7-7-1, 4-3-0) on Thursday would clinch it.

Gunn has done for the men’s soccer program what the Jim Harbaugh/David Shaw tandem did for football — not only putting Stanford on the map but also making it a mecca for top high school players. Gunn has done it the same way he thrived as a player, Tobin said, with “his absolute refusal to lose.”

“He’s been successful everywhere he’s been,” senior midfielder Drew Skundrich said. “It all comes down to his core values as a person and as a coach. He really focuses on the fundamentals of hard work and accountability for everyone on the team. He makes sure that every team he coaches is the fittest in the country. He makes sure we do the little things right, so that we can be more prepared than anyone in the country.”

Gunn goes through scouting reports and opponents’ game video with the keen-eyed scrutiny of his fictional countryman, Sherlock Holmes.

“He makes sure he knows what they’re going to do on set pieces, making sure what formation they’re playing,” Skundrich said. “He goes through every single player (who) touches the field. He knows every little detail about them.”

The coach chalks up his extraordinary success to staying true to his coaching principles and to “hard work and determination. In sport, the sexy notion is that you have coaches who are so incredibly intelligent that they come up with incredible ideas,” he said.

That’s hogwash, he thinks. There are no geniuses in college soccer. “The important thing is keeping a conviction to follow through with what you’re trying to do,” he said.

Stanford wasn’t the only school that pursued Gunn after Charlotte reached the national final in 2011. He picked the Farm, he said, partly because he wanted to surround himself with the great coaches in the athletic department. The locale also played a part. Gunn, who has an MBA, enjoys speaking at Silicon Valley companies about creating a winning culture.

“Leadership, understanding how people learn — those things intrigue me,” he said.

Landing the Stanford job caused one minor issue with his family in England, he said. The Gunns are proud supporters of Leeds United in the Premier League and thus wear blue, white and yellow athletic gear. Red is the main color of rivals Manchester United and Liverpool. When he posted a photo of himself wearing Stanford cardinal on Facebook, he received “a few choice comments from my brothers.”

How long he’ll stay at Stanford is a matter of conjecture among soccer people. “He’s getting looks” from Major League Soccer, Tobin said.

Gunn says he’s very happy at Stanford. He and his wife, Janet — Tobin officiated the marriage ceremony three years ago — have a 19-month-old son, Tomás.

One of the things that strikes him about the way soccer is coached in America is that it might be intense but it’s not “cutthroat,” as it is in the rest of the world. He thinks that might help explain why the U.S. men’s national team did not qualify for the 2018 World Cup after losing to Trinidad & Tobago, a country with a population slightly larger than San Jose’s.

Overall in American soccer, the stakes are not high enough, he said. In MLS, for example, “there’s no promotion or relegation” to a lesser level if a team does poorly. “A top pro at clubs around the world will not continue playing if they’re not performing. The highest-paid players in MLS will play even if they’re not training hard. The same happens in colleges and the youth level.

“In the U.S., it’s not cutthroat,” he said, “so it’s up to the coaches to create a higher compete level.”

Tom FitzGerald is a San Francisco Chronicle staff writer. Email: tfitzgerald@sfchronicle.com Twitter: @tomgfitzgerald