A simple principle is formulated, which makes it possible to explain and, in some cases, to predict the shape of secondary flows of Prandtl's second kind that arise in turbulent flows in straight pipes of non-circular cross-section. The motion along the no-slip wall is directed in the direction of reduction of pressure. Therefore, the direction of the secondary motion along the perimeter of the pipe cross-section can be determined by the location of the mean wall pressure local extrema. Velocity fluctuations along a curved wall cause the mean wall pressure change, the greater the change, the greater the curvature of the wall. Thus, the location of local wall pressure extrema is consistent with the wall curvature. In a number of cases, an approximate picture of secondary flows can be predicted a priori using only symmetry considerations and a wall curvature analysis. The conditions for the formation of a secondary flow change on a free surface where, in addition to pressure, Reynolds stresses act on the fluid particles, and the result of their interaction is unknown in advance. A turbulent flow in a rectangular channel is considered, in which one of the walls (upper) is shear-free. Application of the formulated principle dictates the presence of secondary flows in the upper corners, with a downward motion along the solid sidewalls. This contradicts the popular point of view about the shape of secondary flows in open channels, according to which the motion along the sidewalls is directed upward towards the corner and then towards the centre of the channel along the free surface. The paper presents the direct numerical simulation (DNS) results showing that along with the large-scale secondary flow, which generally agrees with the traditional picture, there is a smaller-scale single-vortex secondary flow with the opposite direction of rotation in the vicinity of each upper corner. The presence of a no-slip wall is an important element of the described mechanism of secondary flow formation. In this regard, the question logically arises about the possibility of the occurrence of secondary flows in the corners between two free boundaries. A series of DNS of turbulent flows in a square duct with two solid and two free adjacent walls have been carried out. It was found that the Reynolds stress forces in the vicinity of the corner between free boundaries are potential, are neutralized by the pressure gradient, and therefore do not create a secondary flow.