It does not work because you have both files being loaded when the page loads. So of course it will be the color of the second file from the start since both files are there.
The page needs to start with one file.
Other option is you load both files, but the rules are based off a class on the body.
file1.css
body { background-color: yellow; }
h1 { color: red }
file2.css
body.alt {background-color: green; }
body.alt h1 { color : blue; }
And with the JavaScript you add the class.
document.body.className = document.body.className==="alt" ? "" : "alt";