Thanks for your message, and sorry to hear this occurred.
As you will be homeless, you will need to contact your local council as soon as possible. They may provide you with priority need and give you interim accommodation.
However, in respect of your situation, you have signed a contract which means you have a legal interest in the property. Just because the owner is selling the property then that interest is not destroyed. This means your tenancy will persist through and after the property sale. You still benefit from all your tenancy rights as described by the law. None of them are limited, altered or restricted by the change of ownership.
You have a right to remain in the property for the entire fixed term period. Whoever purchases the property is forced to accept you as a sitting tenant at least until the fixed term is over. The owner can still use eviction procedures against you, but they need to follow the established rules, and the rules on eviction currently state a 4 month notice must be given. And even then a court order is required as well.
If the correct notice is not given, and they are advising you cannot move in because of a change of mind, then it will be an illegal eviction under the Protection from Eviction Act 1977 as well as a breach of contract.
If they persist you can take the owner/agency to court and for breach of contract and I would also suggest you report the agency to the redress scheme. Every agency should belong to one of two redress schemes. They are The Property Ombudsman https://www.tpos.co.uk/ and The Property Redress Scheme https://www.theprs.co.uk/ To find out which one they belong, please ask them, or check on their website. You will need to first write a letter of complaint directly to the agency. If they do not respond or ignore you, I would suggest you escalate the complaint to the redress scheme above. The redress schemes are free and are designed to resolve disputes like this without the need to go to court.