Growing up on earth with a singular sun, it is hard to imagine what life would be like with two (like the planet Tatooine in Star Wars) or more. In fact, many systems have been discovered with two suns and one was named in fact Tatooine. Furthermore, the planet HD 131399 was just discovered orbiting around three stars, but it by no means represents the limit on the number of suns possible for a solar system. Kaitlin Kratter, a computational astrophysicist at the University of Arizona, says the limit depends on a hierarchy that becomes much more difficult with multiple suns as the orbits become more complicated to balance. She says the thing that gives planets like HD 131399 the ability to orbit around three stars is its relative locations to each. As with most discovered planets that orbit around three stars, HD 131399 is close to its “primary star” (90 AU away) and is relatively far from a binary pair that account for the planets other two stars (~300 AU from each). As a result, the planet is being pulled so hard by its primary star that the gravitational force it feels due to the binary pair is negligible in comparison. Still, it is possible for planets like HD 131399 to eventually be ejected from the system and become a free-floating planet, suggesting that these multi-star planetary systems may be main source of free-floating planets.
As for how these planets become wedged in these crazy, complex orbits, Kratter has multiple theories. For one, many of these planets are huge (HD 131399 is 4 times the size of Jupiter). This suggests that they could have been formed when the three stars were formed, making it more like a four star system where one wasn’t big enough to become a star and therefor stayed large ball of gas. The other theory is that this planet eventually absorbed other planets orbiting the stars, gaining their mass.
As for the original question, it is hard to theorize the limit on how many suns a planet can have in any system. Kratter says the theoretical limit beyond which stars become unbound is between 10,000 and 100,000 AU, meaning that many single star systems still interact slightly with other stars or binary pairs. With this in mind, there is technically no limit to how many suns a planet can interact with in its orbit. Crazy!