Most operating systems will look at the computer file extension to determine what kind of file it is. Some files are executable files (they end with the .exe, .com or .bat extensions) while other files are text files, spreadsheet files or other files meant to be read and interpreted by some program. With Windows, double-clicking on the executable files will immediately run those files.
This can be a double-edged sword if those files contain viruses. That’s why it’s best if you get file attachments that you’re not sure about, don’t double-click them. That will immediately launch them and the viruses will run. At best, rename the file extension to something like “.txt” or something that the computer won’t try to run automatically. Of course the best policy is just to delete those attachments that you’re suspicious of.