How do I stop iCloud from downloading files to my hard drive? I opened up a folder and it immediately started downloading all contents
No it is not possible to stop automatic downloads or delay it.
iCloud is not a backup system, it is a syncing system, so it downloads whatever data is stored there to each computer and device signed in with the same Apple ID. There is no way to selectively download. It is an all or nothing sync. Apple have shown no interest so far in 'online backup' as you describe it, don't rely on that changing anytime soon.
When your storage on your device is almost full, the system will purge data that you do not use often. It will still be stored inside iCloud.
This is the answer, you just push undownload after the download is finished. https://github.com/Obbut/iCloud-Control/releases
This answer is incorrect. This should help... https://support.apple.com/kb/PH25224?locale=en_US&viewlocale=en_US