A multi-million contract has been signed to boost the capability of Royal Navy and Royal Fleet Auxiliary ships.