For most commuter trains they don't actually turn around, there's a control cab on both ends so the operator just walks to the other end and heads out. Most diesel locomotives can operate in either direction. The locomotive just uses a runaround track to pass to the opposite end.