The short answer is that they didn't, really. There was no national "database" of sailors who served on ships; the only thing that would come close are Admiralty records of officers, either warrant or commissioned, who were assigned to particular ships and whose seniority had to be tracked. But they didn't need one!
Unlike today, when we think of enlisting for a "tour of duty" as a fixed term of service, men who enlisted in the Royal Navy would do so for the duration of a "cruise" or a "voyage," which is a very vague and inconsistent length of time. During the 16th century, for example, men might take ship in the spring and pay off in the fall, but during the Dutch wars men's terms of service got longer, on the order of 2-3 years sometimes, partially because the Admiralty (in a time of financial crisis) figured out that they could defer/delay paying off ships by keeping them in commission.
By the time period I'm most interested in, men might stay on board a ship for two to three years, or possibly longer if there was a circumnavigation involved or they were going to a far-off station, such as the East Indies, or even if they were just on one of the interminable blockades that the Royal Navy was obliged to undertake during this time. They wouldn't be paid until the commission ended, except as the captain and purser used their discretion to advance some pay or prize-money if they stopped in a port and were granted liberty. Once the ship did pay off, men would be given tickets that in theory had to be cashed in London, but were often sold off to speculators at a discount so the men would have cash in hand.
During that time period, manning was the responsibility of the ship's captain, maybe with some help from the port-admiral where he might be fitting out. Drafts of men could be transferred from one ship to another; a successful captain might bring followers with him, and there's no doubt that impressed men would almost always make up part of a ship's crew, unless the captain had been very successful. (As an aside, this idea that press gangs would get people drunk and haul them aboard is inaccurate; this was a practice of merchant sailors in California in the late 19th century, not Britain in the early 19th century. The "drunken sailor" trope is a bit of a myth anyhow.)
When men came aboard ship, they would be examined by the surgeon or his mates to make sure they were healthy, and usually interviewed by the ship's lieutenants or possibly warrant-officers, and given a rating ranging from landsman up to able seaman, which determined their pay. Even the merest lubbers could advance in rank, and their pay would reflect that from the date going forward. Warrant officers and commissioned officers had their own hierarchy of promotion.
Desertion was a real problem for the Royal Navy, and men who jumped ship would have an R (for "run") written against their names in ship's books. Men did protest this policy -- there were times when a ship left port without all its sailors due to emergency or other contingencies, and it was considered rather cruel to mark men as deserters who simply didn't make it on board ship.
I hope this answers your question -- please let me know if you have follow ups!