Why do transits of Venus happen?

They happen because, as seen from the location of Earth, a planet (Venus or Mercury) is at a location in its orbit where it intersects the orbit plane of Earth along the Sun-Earth line. The following figure from the Observatory of Paris web site shows the geometry of the orbits.

The orbit planes are tilted a few degrees with respect to each other, and this means that the orbit of Venus intersects the orbit plane of Earth along a line that passes through the Sun. When Venus happens to be at one or the other of the points in its orbit along this 'line of nodes', it will appear to be eclipsing the Sun as seen from Earth if Earth is also located along this line in ITS orbit.