It is necessary for the US to keep pace with weapons programmes in China and Russia, the president says.