The problem is that you are mixing direct register access (BTW don't use magic numbers), arduino specific language (analogRead(), analogWrite()), and Libsam/ASF functions (dacc_set_channel_selection(),dacc_write_conversion_data()).
Once a setup is done via direct registers access for ADC, if you use analogRead() there is a good chance that your previous code will be scratched.
I suggest that you read sections 43 (ADC controller) and 44 (DAC controller) and use only a direct register programming.
And use code tags to show your code (</>)