Kyle Shanahan should have been practically skipping into the auditorium at Levi’s Stadium late Sunday afternoon, but instead he entered with a glum-faced trudge.

The 49ers’ head coach and offensive play-caller had spent the previous three hours watching his team compile historic numbers: The 49ers had just run the most plays (92) in franchise history, had collected their most first downs (33) in 20 years, had 10 third-down conversions for the fifth time since 2002 and had held the ball more than 40 minutes for the fifth time this century.

So why wasn’t Shanahan smiling? The offensive fireworks were mixed with futility.

The 49ers also committed five turnovers, and the miscues explained how they managed to lose 28-18 at Levi’s Stadium to the previously winless Cardinals, whose inept offensive performance was at least error-free.

In the aftermath, the 5-0 turnover margin dominated the discussion.

“You look at a lot of those (statistics), and it’s hard to find how you lost a game,” Shanahan said. “Then it’s very easy when you look at the turnover column. I haven’t been part of any game, I don’t think many people have, where five turnovers to zero leads to a win.”

He’s right, of course. After the 49ers (1-4) had their most turnovers since 2013, teams fell to 6-154-2 since 1970 when committing five more turnovers than their opponent, according to the website profootballreference.com.

Now Playing:

“If you can’t protect the ball,” running back Alfred Morris said, “you lose the game.”

Yes, you lose even if you have a 33-10 edge in first downs. The 49ers became the first team since the 1998 Jaguars to have at least 23 more first downs than their opponent in a loss.

“We’ve just got to hold on to the ball,” left tackle Joe Staley said. “That’s what we talk about all the time. And we did a terrible job on offense of turning the ball over, obviously.”

Fittingly, the 49ers’ latest loss was sealed by a turnover.

Trailing 14-12 with about five minutes left, the 49ers had the ball at their 41-yard line, roughly 25 yards away from go-ahead field-goal range.

However, on 2nd-and-11, quarterback C.J. Beathard had the ball stripped in the pocket by linebacker Haason Reddick and the fumble was returned 23 yards for a touchdown by linebacker Josh Bynes.

It was part of a four-turnover performance for Beathard, who lost another fumble and threw two interceptions.

“You can’t win ballgames turning the ball over five times,” said Beathard, who had a career-high 349 passing yards. “I feel like we played well in all the other aspects except for turnovers.”

Indeed, the 49ers outgained the Cardinals 447-220 in the first career road start for Arizona rookie quarterback Josh Rosen. Arizona managed just 10 first downs, went 2-for-12 on third downs and gained just 145 yards after Rosen threw a 75-yard touchdown pass to Christian Kirk on their first play.

It was Arizona’s only scoring drive of more than 30 yards: The 49ers’ turnovers set up the Cardinals’ other touchdown drives, which spanned 26 and 18 yards.

3 notables WR Trent Taylor: After he had nine receptions in his first four games, he had seven catches for 61 yards and a 1-yard TD catch that trimmed the gap to 14-12 in the fourth quarter. LB Reuben Foster: He had a quiet three-tackle performance and left the locker room with a large ice bag on his right shoulder. S Adrian Colbert: He mistakenly covered WR Larry Fitzgerald, who was running an intermediate route, on Christian Kirk’s 75-yard TD catch on Arizona’s first play. — Eric Branch

Read More

“Oh, my gosh, the defense played great today,” fullback Kyle Juszczyk said. “They kept us in the game. Hats off to them. We appreciate the hell out of them because we did not make it easy for them.”

Said Arizona wide receiver Larry Fitzgerald: “We’ll take all the ugly (wins) we can get.”

And the 49ers will have to absorb their most brutal loss of the season.

Each of their first three defeats came on the road to playoff contenders (Vikings, Chiefs, Chargers), and Sunday’s game was viewed as a much-needed breather before the 49ers travel to Green Bay and host the undefeated Rams the next two weeks.

“We’ve got to figure this thing out now before it gets too far out of hand,” Morris said. “It sucks to be 1-4 right now. It’s definitely not the way we thought this season would be going, but that’s the hand we’re dealt right now.”

Eric Branch is a San Francisco Chronicle staff writer. Email: ebranch@sfchronicle.com Twitter: @Eric_Branch