Donald Trump has banned people from 12 countries entering the US, in a move he said protects against "foreign terrorists" and other security threats.