Composition of canonical port-Hamiltonian systems on smooth and discrete manifolds