Galaxy formation. The internal structure of DM haloes in the presence of baryons