In the field of human–robot interaction (HRI), achieving flexibility in human-accompanying within real-world environments holds great potential for various applications but also poses significant challenges. Traditional methods typically restrict robots to fixed positions relative to humans, such as tracking from behind, in front, or side-by-side, which limits robot adaptability in dynamic workspaces. This study introduces a novel human–companioning strategy that uses reinforcement learning (RL) to enable mobile robots to dynamically adjust their tracking positions according to varying conditions. An interaction space is defined to capture the relationship between the human and the robot while considering the environment, which serves as the basis for the state spaces in the DRL to assist the robot in adapting to environmental changes. A human–robot companion controller is developed by integrating model predictive path integral (MPPI) control with control barrier functions (CBFs), ensuring that the robot accurately follows the target’s movement in both position and orientation while avoiding obstacles and enhancing social acceptance and safety. The proposed approach is evaluated in real-world scenarios, both indoors and outdoors, and compared with those of other studies. The results show that the proposed method improves the success rate (SR) and tracking accuracy by at least 24% and 47%, respectively, while enhancing human comfort. Experiments demonstrate the robot’s ability to flexibly accompany a person walking at speeds of up to 1.7 m/s, dynamically adjusting its strategy without being confined to a fixed position. In addition, the robot respects the human’s intimate space to ensure safety, comfort, and effective obstacle avoidance.