If you plot the log of the period against the log of the semi-major axis then it is obvious that $P^2 \propto a^3$. Any other power law relationship simply wouldn't fit.
The following passage (from https://www.mathpages.com/rr/s8-01/8-01.htm ) seems relevant:
Is it just coincidental that John Napier's "Mirifici Logarithmorum Canonis Descripto" (published in 1614) was first seen by Kepler towards the end of the year 1616? We know that Kepler was immediately enthusiastic about logarithms, which is not surprising, considering the masses of computation involved in preparing the Rudolphine Tables. Indeed, he even wrote a book of his own on the subject in 1621. It's also interesting that Kepler initially described his "Third Law" in terms of a 1.5 ratio of proportions, exactly as it would appear in a log-log plot, rather than in the more familiar terms of squared periods and cubed distances. It seems as if a purely mathematical invention, namely logarithms, whose intent was simply to ease the burden of manual arithmetical computations, may have led directly to the discovery/formulation of an important physical law, i.e., Kepler's third law of planetary motion. (Ironically, Kepler's academic mentor, Michael Maestlin, chided him − perhaps in jest? − for even taking an interest in logarithms, remarking that "it is not seemly for a professor of mathematics to be childishly pleased about any shortening of the calculations".) By the 18th of May, 1618, Kepler had fully grasped the logarithmic pattern in the planetary orbits: