Depth of field and what affects it is very often misunderstood or can seem confusing to new photographers.
The three factors that effect it are aperture, focal length, and distance from the camera, though the last two are related.
Different sensor sizes will also affect the actual Depth of field (or DoF) achieved, but they are not factors the photographer can affect.
To help explain, and demonstrate how each of the 3 settings affects the depth of field, I though pictorial representation would be a good way to show it.
1. Same focal length, same distance from camera, different aperture setting.
2. Same focal length, same aperture, changing distance from subject to camera.
3. Same aperture, same distance subject to camera, different focal lengths.