Measurements of the branching fractions for B(s) → D(s) π π π and Λb0 → Λc+ π π π