You've made an absurd assumption
Which you are perhaps intending to do, to make a point.
You statement, "The rules treat everyone as having 360 degree vision in combat" is just not true or supportable.
You make a further incorrect assumption (again, perhaps to prove a point), that rules for sneaking in combat apply out of combat; for instance, when sneaking past a guard.
So, your two false assumptions:
- The rules of sneaking in combat grants 360 degree vision
- The rules of sneaking in combat apply out of combat
In combat
The rules on hiding on combat say (Basic Rules, Chapter 7, Dexterity, sidebar "HIDING"; emphasis added):
In combat, most creatures stay alert for signs of danger all around, so if you come out of hiding and approach a creature, it usually sees you. However, under certain circumstances, the DM might allow you to stay hidden as you approach a creature that is distracted, allowing you to gain advantage on an attack roll before you are seen.
Note the qualifiers I highlighted. This does exactly the opposite of treating everyone as if they have 360 degree vision in combat. It's saying, "usually you can't sneak up on someone in combat, but sometimes you can" . . . "usually creatures are looking around, but sometimes they aren't".
So, even in combat, the rules do not treat everyone as having 360 degree vision.
The phrase "most creatures stay alert for signs of danger all around" is providing a default narrative for combat. Most creature stay alert, but there could be exceptions. This specifically does not address hiding or sneaking outside of combat.
Outside of combat
As you mention, outside of combat, the rules provide support for a stealth check (Basic Rules, Chapter 7, Dexterity):
Stealth
Make a Dexterity (Stealth) check when you attempt to conceal yourself from enemies, slink past guards, slip away without being noticed, or sneak up on someone without being seen or heard.
It's up to the DM to provide the narrative support for the stealth check. The narrative details of concealing yourself, slinking past guards, slipping away, or sneaking up will determine how difficult the check is.
It's worth recalling that DC stands for "difficulty class", and the rules relate it back to broad categories of "very easy" to "nearly impossible", and furthermore, that the DM can impose multiple checks as necessary, which, of course increases the difficulty.
Fine points need to be adjudicated by the DM
Exactly how the stealth check plays out, the DM needs to adjudicate. It's not a video game -- the narrative matters. A guard might be attending to duty and staring fixedly over the rampart, in which case, they aren't looking behind them. In a different situation, a guard might be much more likely to look behind on occasion; up to the DM, as is how often they look behind.
If the guard doesn't look, they can't see you
If you're sneaking past a guard by sneaking behind them, and they don't look, then they can't see you.
Maybe in that case the DC is 15, "medium", or perhaps higher or lower depending on circumstances. If another party member provides a distraction, the DM can alter the DC, or choose to provide advantage on the stealth check.
If the guard looks, and you're right there in "plain sight", you're no longer hiding
However, if for whatever reason, the guard turns around, and they can see you, then they see you. It's that simple.
Unless there are extenuating circumstances, you're in "plain sight", and you're seen.
Your specific questions
You ask, "Does that mean there would be no way to sneak by a guard that logically has to look the other way from time to time to cover that full range of vision...?"
The DM needs to adjudicate. The rules don't and can't give hard and fast rules for that, and neither can we.
About sneaking up on someone
You go on to ask, "...you cannot sneak up to attack someone if there is any amount of open-view space you have to clear for doing so?"
The DM needs to adjudicate. The rules don't and can't give hard and fast rules for that, and neither can we.
When does being hidden end automatically?
You finally ask, "When does being hidden end automatically?"
It ends when you're detected.
In case more evidence is needed
The rules assume non-360-degree vision. An example is the stealth check quote above, ". . . sneak up on someone without being seen . . .". If the rules assume 360 degree vision, then that phrase makes no sense.
There are other places as well. For instance, the description of the medusa says:
Unless surprised, a creature can avert its eyes to avoid the saving throw at the start of its turn.
If the rules assume 360 degree vision, then "avert its eyes" is weird.
How to handle it as a DM
I feel like there's a subtext to your questions; somehow the rules have let you down, and it's not clear why. It may be that in some circumstance your DM and players aren't seeing eye-to-eye. That might be the real issue.
However, I can tell you how I handle similar situations, and how other DMs in my group handle it.
As you know, the rules say:
The stealth rule quoted above is a pretty good general-purpose rule. Depending on the circumstances, someone attempting to sneak past a guard, I might have them make a stealth check and be done with it. I might set the DC differently depending on circumstances. I might grant them advantage.
The DM needs to decide what level of detail to focus on. Is this a simple check? Maybe a stealth roll is all you need and you don't need to drill into which way the guard was looking. Or maybe you want to drill into it further, "as you spy on the guards, you are pretty sure you can't just slip past when they aren't looking. You can try, but it seems dubious."
So . . . case-by-case, make it interesting, make it challenging, choose level of focus, make a ruling, move on.