1 Regarding Company A, you don't need to sign another agreement. Company A has no right to transfer and license the patent. However, it is certainly possible for Company A to use the patented equipment purchased. Your company can agree with Company A on the scope of application of the technology patent, that is, it is limited to the existing factory of Company A, excluding the new factory.
You should sign a technology license agreement with company B. I don't know the details, but the principle of prior use stipulated in the patent law may occur, that is, before the patent application date, the same product has been manufactured, the same method has been used, or the necessary preparations have been made for its manufacture and use, which is not regarded as infringement.