Sorry to disagree with @Yetanotheruser and @Flarlarlar but under no circumstances do what they recommend and filter your fermented but uncarbonated beer through cloth before bottling. You will 1) introduce a ton of oxygen into your beer, which is the enemy of good beer and will cause oxidation (meaning nasty wet cardboard flavor/smell) but you will 2) increase your chance of infection.
What is happening to your beer? There’s a few things that could be going on. Since it’s only happening in a few bottles of your batch, that narrows it down. Chances are either:
1) You aren’t giving an even distribution of sugar throughout your beer when you prime it. With more sugar in some beers than in others, there is more fuel for the yeast to create carbon dioxide in those with more sugar. This will create higher pressure and foaming. The amount of yeast, as long as it’s reasonable, doesn’t matter. What matters is the amount of sugar. Yeast eats sugar and turns it into alcohol and carbon dioxide. The more sugar, the more carbon dioxide.
or
2) Some of your bottles aren’t clean enough or somehow have some sort of contamination in them, causing those bottles to get infected. Wild yeast and bacteria can consume complex sugars that normal beer yeast cannot, so they will create way more carbon dioxide, hence the foaming.
So, either make sure you stir the sugar into your beer more before bottling, or clean your bottles better and chances are you’ll nip this problem in the bud. Just please please please don’t filter your beer through cloth! That will pretty much mess up, or increase the chances of messing up, all your beer instead of just a few bottles.