Condoms substantially reduce the risk of getting STD's however you can still be unlucky. you are after all still in close contact with the person you fear may have an STD.
Yes, condoms do prevent STD's. However, they are not foolproof. While your risk of contracting an STD does go down significantly, there's still a minute chance that you may contract one.