You may still get sick from being around someone else that is sick but you can try and prevent yourself from becoming sick when near someone that is sick by doing a few things.
When around someone that is sick wear a surgical mask to prevent the spread of germs from the sick person to you and always wash your hands often and if possible avoid skin contact with the sick person.
If you have to touch the sick person then it's best to wear gloves and wash your hands with antibacterial soap with as hot as water as you can stand to kill the germs and also take some cold or flu medicine or get a flu shot to prevent you from getting sick with the flu.
Still you may get sick no matter what you try to do but you can lessen your chance of becoming sick by taking a few precautions.