Formation of a protoplanetary system through the merging of binary components that are contracting towards the main sequence