Cancel first contribution associated to membership, cancels the membership
Following this old topic:
https://civicrm.stackexchange.com/questions/2482/membership-sets-to-cancelled-when-contribution-fails-why
https://issues.civicrm.org/jira/browse/CRM-18177
current CiviCRM behavior is when a Contribution associated with a membership is Cancelled, if this membership has only this Contribution, the membership is cancelled too.
Same when the Contribution gets to "Failed", if it's the first Contribution associated with the membership, it is set to "Expired" status.
https://github.com/civicrm/civicrm-core/blob/5.13/CRM/Contribute/BAO/Contribution.php#L1784
We use Membership for many Organizations with manual/offline payment processors, like direct debit, where the first Contribution can be Cancelled (i.e.: the member has no funds in his bank account) but this doesn't mean that the membership has to be cancelled too. The ORG will reattempt to charge this contribution later, and this same Contribution can be later Completed or a new one charged.
This ticket is meant to reopen the discussion about this topic with other users, and if it worth it, to rework on a solution where this behavior of cancelling memberships is not mandatory
Other areas of the code where similar things happen: