Why do we study the theory of automata before studying the construction of a compiler?

I have studied automata before studying the construction of a compiler. I am at the beginning of building the compiler and learning the basics of this subject, but I do not understand why it is necessary to study the theory of automata. What is the relationship between these two?