How do aircraft designers decide how far from the fuselage should engines be? I am specifically talking about engines that are mounted on, in, or under the wing.
The tendency is to mount the engines as close to centerline as possible. This mitigates control problems in engine out situations and keeps the wing structure as light as possible: if engines were far from the centerline, the structure of the wing would need to be stronger and thus heavier, and should either/one of the engines fail, the running engine(s) would impose a strong yaw force on the aircraft. On low wing aircraft, engines being below wing and far away from centerline, they would limit the bank angle during landings, maybe making crosswind/gusty landings difficult.
Limiting factors on how close to the centerline the engines can be, are ground clearance, propeller clearance, need to be as vertically as close to the center of mass as possible, and the need for undisturbed airflow. If the engines were right at the root of the wing, on a low wing aircraft the landing gear would need to be very long (assuming the most common setup of wings with upward tilt =dihedral). Also, engines being very close to wing root (top/in/below) would lead to problems with landing gear support structures. If the engines are ones with propellers, you need some clearance from fuselage (more than a few inches) for noise and vibration reasons. Although fighter jets often have intakes right next to the body of the aircraft, this is not optimal, so for jet engines also some distance from fuselage is preferred.
So, it is no wonder the sideways distance of engines in aircraft seems to be pretty standard, with little to no variations between different designs.