You borrowed a Mac from a friend and signed out his Apple ID from system preferences > iCloud , and then signed in with your Apple ID and password , the iCloud data start syncing from the server in which iCloud files were are also there , and then you turned off the iCloud drive .
If you had clicked on keep a copy , the files are in the home folder and are archived , but then you came back with your Mac at a different place , that is your home and then again signed in with your Apple ID and password , if you set up iCloud Drive and check the box of desktop and documents see the articles https://support.apple.com/en-in/HT204025
https://support.apple.com/en-us/HT206985
https://support.apple.com/en-gb/guide/mac-help/mchlp1774/10.14/mac/10.14
All the data ( files are saved on the server and will start syncing , make sure you are using the iCloud data in designated limits it could be free 5GB or the plan purchased from the apple , the excessive files will not save on the server , also the files should be compatible .
In your friends Mac , if you had clicked on remove from this Mac , the files are still on the server , also you might had created a folder and moved some files in it , the reset of files are given what type of permissions is there no access or what https://support.apple.com/en-in/guide/mac-help/mchlp1203/mac
And what permissions were given ?
You can once again sign in with same Apple ID and password of your friend and your Mac on the same network https://support.apple.com/en-ke/HT204053 , once all data ( files ) are synced 100 % , move the files into your computer at download folder see the article https://support.apple.com/en-gb/guide/mac-help/mchl1a02d711/10.14/mac/10.14
And then your friend can sign out his Apple ID account from his Mac https://support.apple.com/en-in/HT208242 and should click on don't keep on copy for all applications , in this way your data will not download to his computer and your Mac will be disconnected .
The files are within download folder , you will not found files by clicking on advanced and restoring files as you have not deleted files and they are not gone to recently deleted folder and kept for 30 days , as after 30 days they are deleted permanently from the server .