It looks like the system you locked the project on was using a preinstalled version of OCaml 5.2.1 (so the .locked file contains a reference to ocaml-system version 5.2.1 instead of ocaml-base-compiler 5.2.1).
It’s another manifestation of the weakness of the current lockfile implementation - the workaround here would be either to edit the lock file to replace the ocaml-system package with ocaml-base-compiler or to re-create the lockfile on a system where you’re using ocaml-base-compiler instead of the preinstalled compiler.
The difference is whether the compiler is provided by your system (e.g. in /usr/bin) and just used by OCaml or whether it’s built from sources and installed in the switch (in $(opam var bin)).
On the host, you should be able to change it with opam switch set-invariant ocaml-base-compiler.5.2.1 which should then build the compiler (and will rebuild the entire switch with it) and then if you recreate the lock then it should use ocaml-base-compiler.5.2.1 instead of ocaml-system.5.2.1.
In the Octez repository, the script which updates the lock file actually removes the definition of the ocaml-system package so that Opam cannot use it. This is only possible because the script actually clones the opam repository (see lines 52-72).