In English Law (and in many other jurisdictions) it's only a legal contract if "consideration" is given by both parties; i.e. Palantir here must charge something in return for it to be an enforceable contract.
The UK is still under EU law, as they haven't fully exited yet.
The citizens would still have to agree to allowing their personal data to be processed by third-parties and consent for their data to be processed outside the EU.
Is there any evidence that this consent was given?
The UK government may try to wiggle out of it by using the GDPR exemptions related to research and/or national security https://gdpr-info.eu/art-23-gdpr/