Imports and exports both declined, retreating from a busy month in May, data from the Commerce Department showed.