Let $\,G\,$ be the function defined as $\,G(x)=f(x)-x^2$ for all $\,x\in\Bbb R\,.\,$ Without using continuity, we can prove that $\,G(r)=0\,$ for any $\,r\in\Bbb Q\,.$
Let $\,\varphi\,$ be the Euler’s totient function.
For any $\,r\in\Bbb Q\,$ there exist $\,a,d\in\Bbb Z\,,\,$ $b,c\in\Bbb N_0=\Bbb N\cup\{0\}\,$ such that
$r\!=\!\dfrac a{2^b(2c\!+\!1)}\;\;,\qquad$ $2^{\varphi(2c+1)}\!=\!1\!+\!(2c\!+\!1)d\;.$
Since $\,G(2^nx)\!=\!4^nG(x)\,$ and $\,G(x\!+\!m)\!=\!G(x)\,$ for any $\,n,m\in\Bbb Z\,$ and for any $\,x\in\Bbb R\,,\,$ it follows that$$4^{\phi(2c+1)+b}G(r)=G\!\left(2^{\phi(2c+1)+b}r\right)=G\left(2^br[1\!+\!(2c\!+\!1)d]\right)=G\left(2^br\!+\!ad\right)=G\left(2^br\right)=4^bG(r)$$Consequently , $\;G(r)=0\,.$
It means that $\,f(x)=x^2\,$ for any $\,x\in\Bbb Q\,$ even if the function $\,f:\Bbb R\to\Bbb R\,$ is not continuous.