Insecure cats will be overdependent, so it’s possible that following you to the toilet or whenever you’re out of sight is a sign of an anxious cat needing reassurance.
Bathrooms are usually the quietest room in the house, so cats see an opportunity to escape the busy household and get some sleep, knowing that the only person in there is you.