When a project uses the file rust-toolchain.toml or rust-toolchain (https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file), it is possible for the project to override the optimizer's Rust version. What will happen is that a different Rust version is downloaded and used during the build. However, the toolchain will be incomplete with missing target wasm32-unknown-unknown.
Now looking at the order of toolchains used we see that setting e.g. export RUSTUP_TOOLCHAIN=1.72.0 overrides a project-specific setting. This ensure always the version of the optimizer is used, which is what we want.