Are you copying the credit memo from the first AP Invoice, or creating it as stand alone?
There must be a difference in the item cost between the documents.
You can manually enter an item cost to be used in a credit or return document, which should help you to align your COGS entries