Well, there are a few factors here. Bear with me I'm going to use gallons on this comment. Did you let the beer ferment all the way out? That is very important for reasoning when to rack to a secondary. When you do rack to your secondary...do you use a 5 gallon glass carboy? Also, what size of batch are you brewing...I ask this because if you are doing a 5 gallon batch...you should ferment in a 6.5 and have your secondary be a 5 gallon.
On a side note...if you did let your primary ferment all the way out...there is such a thing called rousing your yeast. This does happen and can be prevented by "shaking" your primary to rouse the yeast in the initial container. In other words, sometimes if your beer hasn't fermented all the way out, it will rouse the yeast when you stir it up to your secondary.
Another factor can be that Co2 is being released and can cause extra bubbling...but I'm willing to bet that since you said yeast got into your airlock in the secondary, either you have a very small container and it's releasing Co2 or you didn't let it ferment out all the way before you transfered.