Though it's not possible to prevent infestations 100%, here are some tips to follow to reduce the risk.
Be alert for swarms from March to July. This is when most are looking for a new home.
Keep clutter and junk out of your yard. Don't give them a suitable home.
Seal up the outside of your home. Cracks in soffits and siding give access to a dry, warm place to build a hive.
Remove all honey and honeycombs from previous infestations. They can attract swarms looking for a home.
Swarms of bees tend to stick around for just a few hours, although they can stay for two or three days. Given the right conditions, bee hives can last indefinitely, as bee colonies are self-sustaining. The queen is the heart of the hive and can live for up to five years. As she begins to age and weaken and her egg production drops, the worker bees kill her and begin to raise a new queen to take her place.
Worker bees live up to six months if born in the fall, but only 40 days when born in the spring or summer. Drones live between three weeks and three months. But the queen lays a steady stream of eggs that quickly mature to replace those that die.
If bees are collected early morning or late evening when most of the bees are in the hive, they most likely will not attempt to come back, as they'll stay with the queen in their new location. However, if there are enough stragglers, they may attempt to start a new colony in their old home if you haven't removed all traces of it. Make sure you remove all honey and honeycomb, seal any obvious points of entry, and try using bee repellent spray to keep them away.
Ideally, you should remove a bee’s nest very early in the morning or late evening, when all of the bees are in the hive. You can also do it after dark, if you can set up enough artificial light to see clearly.
Bees don't fly at night so, although they may buzz and make a little bit of a fuss, they won't fly or swarm, so you'll be able to get the whole colony out in one go, safely. The bees are at risk of being slightly more active in the early morning or late evening, but most of the bees will be in the colony, so you won't leave many stragglers behind.