When they are young, they are free floating and can explore the seas as they see fit. Then, without really realizing it, they start to secrete a gluey cement from a specialized gland. Once they've started producing this bonding agent, wherever they touchdown next becomes their permanent home. It would be like going out for a walk one day only to discover that your feet had suddenly begun to ooze epoxy and where you stopped walking was where you'd spend the rest of your life.
It wouldn't be much of a stretch to say that people and barnacles have a few things in common. When the time comes, you quit floating free and attach yourself to a family. At least that's how it worked with me.