As a marine
biologist I can give you a technical explanation if you want.
Barnacles release larvae into the water
column whereby the offspring develop while floating about at sea. Once the larvae get to a certain stage of development they start looking for something to attach to so that they can metamorphose into a barnacle and go about their regular daily barnacly business, like all the other barnacles do. There are generally way more larvae looking for somewhere to settle than there are spots to settle and these larvae are in coastal and oceanic waters, just hanging about trying to find some suitable substrate.
When your boat is in the water it will come in contact with barnacle larvae and if there are unprotected or inadequately protected areas that larvae can settle and attach to, they will.
Although your boat may be your pride and joy, your home, etc unless its covered in chemical deterants, to a barnacle larvae it just looks like a great place to set up shop and go about the business of filtering plankton.