It’s like company A collects everyone’s phone number and then publishes it as a phone book. And then company B copies the phone book and publishes it as their own.
It’s not a straightforward copyright issue but in many jurisdictions that is not allowed. Company A did the work, they should be allowed to profit.