BAMO 2024 Problem 4

Find all polynomials f that satisfy the equation

\frac{f(3 x)}{f(x)}=\frac{729(x-3)}{x-243}

for infinitely many real values of x.