Ghosts do not seem to be restricted to areas they had been in while alive - presumably, Myrtle was never in a toilet while living.
From what has been shown of ghosts, it seems unlikely that they can only go where they’ve been while alive, unless they can go into new places if they’re in a building they’ve been in before because Myrtle goes into several parts of Hogwarts she almost certainly had not been while alive. She’s been flushed down a toilet into the lake, and she would not have been through the Hogwarts plumbing while alive.
“Underwater …’ Harry said slowly. ‘Myrtle … what lives in the lake, apart from the giant squid?’
‘Oh, all sorts,’ she said. ‘I sometimes go down there … sometimes don’t have any choice, if someone flushes my toilet when I’m not expecting it …’
Trying not to think about Moaning Myrtle zooming down a pipe to the lake with the contents of a toilet, Harry said, ‘Well, does anything in there have human voices? Hang on –”
- Harry Potter and the Goblet of Fire, Chapter 25 (The Egg and the Eye)
It was unlikely that she was ever in the Prefect’s bathroom while alive, since relatively few students are ever made Prefects, and if she died before her fifth year she would have been too young to be eligible to be one, but she goes into the Prefect’s bathroom to spy on them.
“Oh … I see …’ said Myrtle, picking at a spot on her chin in a morose sort of way. ‘Well … anyway … I’d try the egg in the water. That’s what Cedric Diggory did.’
‘Have you been spying on him, too?’ said Harry indignantly. ‘What d’you do, sneak up here in the evenings to watch the Prefects take baths?’
‘Sometimes,’ said Myrtle, rather slyly, ‘but I’ve never come out to speak to anyone before.”
- Harry Potter and the Goblet of Fire, Chapter 25 (The Egg and the Eye)
Additionally, she likes to sit in the U-bend of the toilet, which she also presumably has never been in while alive.
“I don’t know … I was just sitting in the U-bend, thinking about death, and it fell right through the top of my head,’ said Myrtle, glaring at them.”
- Harry Potter and the Chamber of Secrets, Chapter 13 (The Very Secret Diary)
Therefore ghosts are not strictly restricted to only places they have been while alive. There is a possibility that they might be restricted to only staying within buildings they have been in while alive, but this seems less likely, as their soul would still not have travelled those areas of the building.