It is highly dependent on the design of each individual lens. Canon and Nikon lenses fall into two major groups regarding this:
Lenses with full time manual focus. These lenses allow you to turn the focus ring at any time without fear of damaging the focus motor. The design of the lens allows the mechanism between the focus motor and the focus ring to slip, so that turning the focus ring does not force the focus motor to move. For Canon all ring-type USM and STM lenses fall into this category. For Nikon, all SWM and AF-P lenses do as well.
Lenses without full time manual focus. These lenses are designed in a way that the focus ring and the focus motor have a direct connection and turning the focus ring when AF is switched on results in forced movement of the focus motor. Doing so has the potential for damaging the components of the AF system, especially if the focus motor is engaged at the time the focus ring is turned.
As a general rule, Canon lenses designated USM (for Ultra Sonic Motor) and Nikon lenses designated SWM (for Silent Wave Motor) may be manually focused at any time, regardless of the position of the AF/M switch. The M position on USM and SWM lenses allows the photographer to set the focus once and not have it move each time the shutter is half-pressed. Lenses not designated USM or SWM (or the newer STM and AF-P types) need to be manually focused only when the AF/M switch is in the M position.
One quick way to tell is to observe the focus ring during AF. If the focus motor also moves the focus ring during AF, you should not manually focus the lens when the AF/M switch on the lens is set to AF.
Your EF 50mm f/1.8 lens should not be manually focused when the switch is set to AF, even if the lens isn't mounted to a camera. It can potentially damage the motor or gearing of the lens to do so. If the motor is not energized and the movement is fairly slow, it probably won't harm the lens, but it could.