From my understanding, it’s a matter of perspective.
For instance, if we’d like to test whether two variables are dependent (i.e. somehow related). A test of independence is fine to use. This seems apt to use as we suspect some form of correlation between the data sets we’re looking at here.
Yes, you could equally decide to check the “goodness of fit” and compare observed values to check if they match some hypothesised distribution.
But either way, we’re doing the chi test, and either way, the results come up the same. Happy to be proved wrong here— i.e. let me know if we somehow don’t get the same answer. If that’s the case, I’d honestly like to know and learn!