You don’t have to declare networks in your compose files, but be aware that each stack will automatically create a bridge network for you. If you’re using different compose files, then the stacks will be on different bridge networks. Try adding
network_mode: bridge
to both of your compose files.