Hiding works pretty much like you think it does
Most of the relevant rules are freely available online, here.
1. Do I roll a d20 + DEX (stealth) when I first want to hide, and note down the number?
That's basically it. Generally the check will be requested by the DM when the player informs them that they wish to hide, rather than rolled pre-emptively by the player.
Remember, no one can hide in plain sight - a DM might not let you attempt to take the hide action if there isn't anywhere for you to conceivably hide. A mean DM might let you take the action but tell you it automaticially fails, if you try to hide somewhere inappropriate.
However long you remain hidden, normally you won't need to reroll a new stealth check, unless something changes.
2. Then, for each turn that a creature is actively looking, do they roll a WIS (perception) for it and compare this against the written value?
Right again, Wisdom (perception) is the normal way to detect the presence of something hidden.
That said, a creature wouldn't usually be 'actively looking' for multiple turns. Certainly a lot of DMs wouldn't allow that. If a failed check can be easily rerolled on the next turn then it has no consequence. Many DMs would tell the PC that 'it looks like maybe there was no one there after all' if they fail to find someone. Carrying on actively looking under those circumstances could be considered a bit meta-gamey.
I might occasionally allow a PC to reroll a failed perception check, but only if they had a good in-character reason to believe they'd missed something the first time. I certainly wouldn't let them roll every round. Whether you do is up to you - bear in mind this guidance from the DMG:
Sometimes a character fails an ability check and wants to try again. In some cases, a character is free to do so; the only real cost is the time it takes.[...] In other cases, failing an ability check makes it impossible to make the same check to do the same thing again.
If a PC wants to make a particular check with extreme care, taking more time in game to make sure they haven't missed something, then we could use passive checks which 'can represent the average result for a task done repeatedly'. However, that won't help them much as their passive perception should probably already be treated as the floor to their active perception rolls. That being the case, I would let them take 10 minutes and reroll instead.
3. If a creature isn't actively looking, do I instead compare its "WIS (perception) score + 10" to the written value?
Three in a row! That's the right way to calculate passive perception. Sometimes people notice things that they aren't actively looking for - just like real life.
4. What happens when a "check" results in a draw. Who "wins" here?
When two characters make competing ability checks this is what's called a Contest or an opposed check.
If the contest results in a tie, the situation remains the same as it was before the contest. Thus, one contestant might win the contest by default.
What does it mean when it says that 'the situation remains the same'? Luckily there's a couple of handy examples...
If two characters tie in a contest to snatch a ring off the floor, neither character grabs it. In a contest between a monster trying to open a door and an adventurer trying to keep the door closed, a tie means that the door remains shut.
So, in a contest where one creature is trying to hide and the other is trying to see them - nothing changes - the creature remains visible.