Ansible - merging inventories to share variables across?
While I haven't worked with plugin: aws_ec2, here's some general Ansible information that might help you:
The order of inventory files matter; the files given first will be read first; the ones read last will take precedence.  In your execution, you're referencing secrets.yaml last, so when aws_ec2.yaml is read, the secrets are still undefined.
You're trying to define a variable based on another variable with the same name.  That's asking for trouble; rename the reference variables, as that will help you debugging.
When defining variables for the inventory, it's generally better to not do that directly on the inventory itself.  See the link below on how to do that:
https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#organizing-host-and-group-variables
Finally, keyed_groups, regions and all these other keywords are specific to aws_ec2, and they'd work because you have plugin: aws_ec2 at the top of the first file.   You have no such definition on secrets.yaml, so Ansible would probably treat it as a normal inventory file, where that structure would not be accepted.  Your approach here is probably wrong, then.
Again, I never used that inventory plugin.  It may be the case that the inventory plugin does not allow for variables at that point.