When multiple planets line up in space, the phenomenon is called "planetary alignment." According to Universe Today, the different axial tilts of the planets do not allow them to ever line up perfectly. However, they do all fall into the same quadrant once every few centuries.
Quadrants are sections of the Milky Way galaxy that radiate out from the Sun. Each quadrant is equal to 90 degrees of a circle. Universe Today estimates that all planets in Earth's solar system line up in the same quadrant about once every 200 years. NASA also adds that precise planetary alignment, where all planets align exactly, has probably never happened.