There are several factors at play when it comes to the forming of a cavity. You have tooth shape, the amount of saliva that is in the mouth at any given time, and misalignment of the teeth. When you put those factors together, in any order, or even two of them in any order, you are going to see cavities form.
To get a better understanding of why this is the case, read: WHY CAVITIES MAY BE AN ISSUE