No Claims Discount (NCD) is built up over time when you do not claim for an accident. The more years that have passed without you making a claim means you get a larger discount on your policy cost, because you are considered a lower risk to insure. When you have a fault claim or a split fault claim then your NCD will step back by 2 years. If you not claimed for have over 4 years, most Insurance companies will offer to Protect your NCD for an extra payment. This usually means they will let you have 2 fault or split fault claims within a five year period before your NCD starts to reduce.
If you have an accident that is not your fault then this will not affect your No Claims Discount as long as your insurance company claims all the costs of your repairs back from the other Insurance Company. If your Insurance company is not able to claim the costs back (because you did not get the other vehicles registration number or the other driver was not insured), then it will be considered a claim on your policy regardless of whether you were at fault or not, as your Insurance company paid for your repairs but could not claim their costs back.
NCD is applied to the overall cost of the policy. Your premium is calculated by your driving history, previous accidents, where you live, where vehicle is kept overnight, if you use it for business etc. Once the premium is calculated that is when what ever No Claims Discount you have is applied. That means if you do have an accident but have protected NCD, your premium will still increase as you are seen as a higher risk, it just means the same discount will be applied to a higher premium.