Yes unless a contract is written and payment fulfilled. Anything that freelancer creates belongs to the freelancer not the buyer.
This is one big legal difference to freelancing and employment.
Yes without a contract the freelancers are legally entitled to sell the code (it’s not yours) to anybody else.
In any creative venture, be it artwork, fiction writing, markup writing, coding, music, film.... the "work" is copyrighted and owned by the creator the moment it is created.
There are only 9 ways the author "loses" rights to the work. William Fisher, of Harvard Law, has an excellent lecture on copyrights. Specifically Lecture 5 part 3 ...