Chemical imbalance (as a cause of depression or anxiety) is just a hypothesis (one of many). It's heavily used for marketing, because people can easily imagine something behind it, that's easily corrected by what companies sell (more chemicals), but it's most probably nonsense.
Though your underlying point is observably valid. People can get into a state where it's hard for them to improve their well being without outside intervention.
As someone who had such a chemical imbalance that was corrected by medication, I can assure you it's definitely not nonsense (although I thought the same as you until I went through it myself).
I appreciate that you took pills and felt change. It, by itself, doesn't prove that there's a specific chemical imbalance in the brain, or that it causes depression or anxiety.
What science? Most of it is focused on whether the drug has effect compared to placebo/other pills, what unintended effects it has, and not on trying to understand how brain works.
Pill may have effect, yet the hypothesis may still be nonsense. Chemical imbalance hypothesis is really old, and doesn't account for a lot of new information since last 50-60 years.
It's in principle the same problem as when psychotherapists/clinicians try to develop a theory of mind. The result is that we have several major contradictory theories of mind/schools of psychotherapy, and all of them work/are helpful. Yet the usefulness can not be used to validate the underlying theories of mind the methods are based on, because that would mean that all of those theories are valid.
Though your underlying point is observably valid. People can get into a state where it's hard for them to improve their well being without outside intervention.