Possible permutations of a grid
If the tiles were distinguishable, we could permute them in $25! $ ways, since for the first tile there would be $25 $ places, for the second one $24 $ etc... But now we can still interchange tiles of a given color with themselves (and leave the permutation "the same"). For instance the red tiles can be permuted between eachother in $5!$ ways. Therefore the final answer should be (divide by $5!$ for each color):
$$\frac {25!}{5! 5! 5! 5! 5!}=\frac{(5^2)!}{(5!)^5}=623360743125120$$
Usind the same reasoning, for an $n \times n$ grid we get:
$$\frac {(n^2)!}{(n!)^n}$$
Now note that the total number of permutations has nothing to do with the grid being a square, so we can generalise even further, to a grid with $k$ tiles and number of tiles per colour $n_1,\cdots,n_m$ (with $n_1+\cdots+n_m=k$). Then we get:
$$\frac{k!}{n_1!*\cdots *n_m!}$$ different permutations.