Comparison of forward hadrons produced in muon interactions on nuclear targets and deuterium