Software qua property is protected by copyright *perhaps patent, in some jurisdiction). The general rule is that whoever creates the thing (book, song, software) has the exclusive right to the thing. If an employee of Company 1 writes software for Company 2, that employee might (rarely) hold the copyright, but typically that scenario would involve a "work for hire", where the employee is hired by Company 1 to do such tasks as part of his duties with Company 1 (which might then be given to Company 2). This would then be a work for hire, and the copyright is held by Company 1. If the actual author was an independent contractor, he would hold the copyright – see Community for Creative Non-Violence v. Reed for analysis of the subtle nuances in making that determination.
The concept "work for hire" which crucially involves the "employee" relationship would not be applicable to Company 2 paying Company 1 for a product, and as long as the actual author is an employee of C1, C1 has not created a "work for hire" in the legal sense. Without some explicit disposition of copyright, Company 2 is in a sketchy position. Since C1 holds copyright, they must grant a license to C2 so that C2 can legally use it; or, C1 must transfer copyright to C2. This does not happen automatically, and (if C1 does not want to remedy the situation after the fact) C2 would need to take C1 to court to force a resolution to the situation. At that point, the issue would be what C1 implicitly promised, even though they didn't put it in writing. It is likely that the initial exchange was along the lines "Can you make us a program that will do X?", and the answer was "Sure, that will cost Y", and then "Okay, go ahead, looking forward to the product". The courts would not simply say "Well, you didn't explicitly require a license, so you don't get to actually use the software that you paid for". However, it's a somewhat open question whether the court would order a license (of what nature?) or a transfer of copyright. The disposition would depend heavily on the facts of the case (what was said, what C1 actually did, what kind of business they are, what did creating the work involve...).