Hi KerZhi,
What Zvika writes seems correct. I replicated the issue and always get two additional posting lines when the posting profile that was used for posting the customer invoice differs from the one that is used when posting the customer payment. Please test it once again yourself and I believe you will be able to replicate the issue.
The question is then why your posting profile differs. The only situation I am familiar with are prepayments that are recorded with a specific posting profile and payed with another posting profile. Might this be the case?
Best regards,
Ludwig