The general idea of iCloud Drive is that all the files are kept locally in a folder (really, it's just a folder) called "iCloud Drive." Those files that are in the iCloud Drive folder are copied to iCloud.com every time they're updated, so that they can be accessed by other devices. But the files remain on the Mac.
This changes a bit if you have limited storage on the Mac and you choose to "Optimize Storage." In that case, since you've told the Mac that you don't have much room, some less used files can be removed to save space. And to access those files you have to be connected to the internet, so you can download them for use.
If you don't need to Optimize Storage on you Mac, then don't turn that on. Then your files will not be removed.
You didn't tell us what Mac and what OS you're using. But if you have macOS 15, then you can use Optimize and still specify certain files to be kept on your Mac, no matter what.
In macOS15, if you right-click a file in iCloud Drive, then you get a pop-up menu like this:
You can choose to Keep the file Downloaded. In that case it gets a new icon in the iCloud column showing that this file stays downloaded.
So, if you're using macOS15, it looks like your problem is solved. Does this work for you?