To achieve your goal, you want to factor out \(\displaystyle{\left({1}+{\sin{{x}}}\right)}\):

\(\displaystyle{\left({1}+{\sin{{x}}}\right)}^{{2}}+{{\cos}^{{2}}{x}}+{2}{\left({1}+{\sin{{x}}}\right)}{\cos{{x}}}=\)

\(\displaystyle{\left({1}+{\sin{{x}}}\right)}^{{2}}+{\left({1}−{{\sin}^{{2}}{x}}\right)}+{2}{\left({1}+{\sin{{x}}}\right)}{\cos{{x}}}=\)

\(\displaystyle{\left[{\left({1}+{\sin{{x}}}\right)}+{\left({1}−{\sin{{x}}}\right)}+{2}{\cos{{x}}}\right]}{\left({1}+{\sin{{x}}}\right)}=\)

\(\displaystyle{\left[{2}+{2}{\cos{{x}}}\right]}{\left({1}+{\sin{{x}}}\right)}={2}{\left({1}+{\cos{{x}}}\right)}{\left({1}+{\sin{{x}}}\right)}\)

\(\displaystyle{\left({1}+{\sin{{x}}}\right)}^{{2}}+{{\cos}^{{2}}{x}}+{2}{\left({1}+{\sin{{x}}}\right)}{\cos{{x}}}=\)

\(\displaystyle{\left({1}+{\sin{{x}}}\right)}^{{2}}+{\left({1}−{{\sin}^{{2}}{x}}\right)}+{2}{\left({1}+{\sin{{x}}}\right)}{\cos{{x}}}=\)

\(\displaystyle{\left[{\left({1}+{\sin{{x}}}\right)}+{\left({1}−{\sin{{x}}}\right)}+{2}{\cos{{x}}}\right]}{\left({1}+{\sin{{x}}}\right)}=\)

\(\displaystyle{\left[{2}+{2}{\cos{{x}}}\right]}{\left({1}+{\sin{{x}}}\right)}={2}{\left({1}+{\cos{{x}}}\right)}{\left({1}+{\sin{{x}}}\right)}\)