I want to know when we enter a command in a shell then how does the computer recognize that command?
Does it match that command with something already stored in files?
Text committed to be interpreted as a command is assumed to be a phrase (to avoid any term with a special meaning) in the command language of the system (here:
Shell (and "layers" beneath)) that shall assign meaning to it (and cause appropriate effects).
A command language is one instance of a formal language.
Many command languages, including shell allow programming: their languages are programming languages.
Formal languages in general, programming languages, interpreters and compilers are notable topics of computer science as is operating system principles.