Is there any distinction between "source code" and "source files" in a technical context?
My interpretation of this is that a "source file" is a distinct file on a file system that contains source code. "source code" refers to a set of instructions that could be compiled into an executable program, or a library that could be used by a program.
Usually source code is contained in a source file. Cases where this might not be true are situations where a program generates source code in memory and then compiles it. The output object (.exe, .dll, whatever) might be saved to a file, but the generated code might never be saved to a file. If the code generator reads a preferences/configuration file to tell it how to generate the code, I'd call that config file a "source file", but not "source code" since it doesn't get compiled. If the generator operates via a gui and user interaction, then there might not be any source file, and the source code would only exist in memory while the program is running.
A stored procedure is another one which might be tricky: If the author doesn't save the procedure to a file in their local file system, the only other place the code exists is in the database. In Oracle, I think there's actually a table somewhere that stores the code of procedures, but I don't think that data gets stored in a separate table. So in that case, the source code of the procedure is contained in the same file as database data so I don't think you'd have a source file, just source code.
Another situation might be if you have VBA code embedded in an Excel spreadsheet. The spreadsheet contains source code, but it is more than just a source file, as it may also contain data.
Some would say that an example source file that does not contain source code might be something like a DML/DDL file for a database. I'd say they that in a strict sense, they are not source files since they don't get compiled into a program. I might prefer to call them "environment setup files".
Is there any distinction between "source code" and "source files" in a legal context?
I really think you should ask a lawyer who specializes in this area.