Why aren't all planets in the same plane?
Obviously all planets are not in same perfect plane. Because if at all they were in the exact same plane, it would mean that Mercury transits and Venus transits would not be that rare.
Any explanation would be much appreciated.
Short answer -- no; see, for example, https://en.wikipedia.org/wiki/Orbital_inclination.
Possible duplicate of Why is the solar system often shown as a 2D plane?
Your reasoning is correct: if Mercury orbited in the same plane as Earth, we'd see it transit the Sun every 4 months or so. In fact these orbital planes are inclined 7 degrees to each other, and the other major planets' orbits are inclined 1 to 3 degrees relative to Earth's.
The planets perturb each other's orbits slightly, so no planet's orbit is perfectly planar.
However, the Solar system average plane of all orbits and rotations is
and most individual planets' orbits will remain near it for millions of years.