What copyright reaches in code
Copyright protects the written expression in software, meaning the source and object code and some elements of its structure, from the moment it is fixed. It does not protect the underlying idea, the functionality, or methods of operation, so a competitor that writes its own code to do the same job is usually not infringing. Where there is no literal copying, disputes often turn on how much non-literal structure was taken and whether that structure reflects creative choices or was dictated by efficiency and outside constraints. Interfaces and similar elements have produced hard-fought cases with fact-specific results. For some features, a patent or trade secret protection fits better than copyright, and many companies rely on more than one.
Ownership is where problems hide
Code written by employees within the scope of their jobs generally belongs to the employer. Code written by independent contractors usually does not, unless there is a signed written assignment, because the categories of commissioned work that can be treated as made for hire are narrow and ordinary software rarely fits them. Open-source components bring license terms of their own, and some licenses attach conditions to distributing modified code. Investors and acquirers tend to check all of this in diligence. Gather your contractor agreements, employee invention assignment agreements, and an inventory of third-party and open-source components.
Registering and acting on copying
For works first published in the US, registration with the Copyright Office is generally required before filing an infringement suit, and registering earlier can affect which remedies are available. The Office accepts a deposit of selected portions of source code, and redacted deposits are possible when the code contains trade secrets. If you suspect copying, preserve the versions and commit history that show when your code was written, and do not try to access a competitor's systems to find out. With a software ownership question, we usually sort out ownership, registration status, and whether the issue is copying of code or something copyright does not reach.