If I install a game on my Windows machine, does it potentially have access to all my files and folders?
If not, what is preventing this access? How would a game be different from other software that's able to access my files? (e.g. a text editor.)
An application is simply a set of executable files and other resources. The distinction between different types of applications might appear simple to you, but to a computer there is no distinction. It's all just binary.
When you launch an application, you're really creating a process. A process is a unit of work on your computer, usually representing a particular application or service. When a new process is created, it is assigned an Access Control List (ACL) based on your current permissions. So if you, as a user, have access to a file, so do any processes you create. Processes can voluntarily drop permissions, but they will still initially have the same permissions as you do.
There are ways to run processes as users other than yourself, provided you have the credentials of that user. If you're logged in as an administrator, you might want to run the process as a limited user instead, via the runas command, or by altering the shortcut settings.
If you're looking to fully sandbox and application (i.e. prevent it from making any system changes) there are a couple of routes you can take. The first is an application such as Sandboxie, which puts the process in an artificial cage. It's pretty effective and isn't too bad performance-wise, but it can sometimes break functionality. The second method is to use a virtual machine, such as VirtualBox. This creates an entire virtual computer, onto which you can install a full operating system. This offers near-perfect isolation, but does incur some performance overheads, especially with 3D and video. However, virtual machines are amazing tools for testing the impact of a particular bit of software (or malware!) because you can allow it to trash the system, then just revert back to a snapshot when done, all without risking the valuable data on your real operating system.
If you're worried about malware (viruses) you can use tools such as VirusTotal to check small files against a selection of anti-malware products, but keep in mind that they are not a foolproof solution. They rely on signatures of real malware that has been analysed by the AV company, which means new malware can slip through unnoticed. There have been improvements in this field, such as behavioral analysis and heuristics, but it's still nowhere near 100% secure.
Programs installed on your machine have (at the very least) the same permissions you do. It's even possible for them to gain elevated permissions which you do NOT have. As far as the OS knows, it's an application like any other. The OS makes no distinction between a "game" or "text-editor"... or even "virus" for that matter. Anti-virus programs can "detect" known patterns and stop viruses before something bad happens...