A protein may have several hundred amino acids linked this way. The red amino acid on Line 1 is alanine. The blue amino acid is glycine. When they split out water to form a dipeptide, either could be the donor for either a hydrogen or a hydroxyl. If a chemist cooked up a mixture of alanine and glycine, the 4 possible products would form.
Nature uses specific enzymes to make the one desired product.
Note that the dipeptide still has an amino group and a carboxyl group that can react further. If it splits out water with the dipeptide to form a tripeptide, one of the possible products is shown, alanyl glycyl serine. Note the the tripeptide has a carboxyl group and an amino group that can react further. Note also the hydroxyl group. Proteins that are made up of amino acids with extra functional groups will have these in their structure.