how are chemical compounds formed?