There is no need for the file extension to match anything specific, as you correctly found out.
On Unix-like systems, file types are usually derived from the content of the file (i.e. the "magic number" or other characteristic structures in the first few bytes) and not from their name. You could also completely omit the extension, which is often done for executables.
file command, it shows you the information it can find out about a file type from its content.
For an executable script, the system expects a so-called "shebang" in the first line, which looks e.g. like
and indicates which program to run as interpreter with the script file as argument. If you execute a text file without such a shebang, it will use your default shell, i.e. Bash to try and interpret it.
So on Unix/Linux systems, file name extensions are mostly a hint (but no guarantee) for the human user to quickly recognize what to expect a specific file to contain. It's also a convention that can help e.g. finding files faster.
Note that there are some exceptions though, where the name and extension matters (e.g. some system config files which must follow a naming convention, or many image viewers and editors also require the extension to indicate the file type).
You can also have a look at Do file-extensions have any purpose (for the operating system)?