Regimen of 3 shots, month 1, 2, 6. First two shots for efficacy, last shot for memory cells. Efficacy rate of first shot around 65%, 2nd shot jumps up to 90%++. Booster recommended after 10 yrs.
If you got vaccinated 4 yrs back and it took (meaning you're in 90%++ group that it worked for), you can't contract Hep B. What might happen is your titre levels for hep b antibodies are very very low but as soon as you come into 'contact' with virus, antibodies kick in to protect you against getting hep b infection.
Check for antibodies - you can be HsB antigen positve but also have antibodies, then you're safe
The above is the theory. Can't help with hep C.