Models are normally not permitted to shoot at enemies that are engaged in close combat, for the simple reason that there's too much danger of hitting a friend! Remember that while a fight may look like two separate blocks of troops fighting head-to-head, it's actually a swirling melee where no one stays still long enough to offer a safe shot!
However, if a unit is within 4" of an unengaged arc of an enemy unit in close combat, it may attempt to fire at them. At this distance they are close enough to be able to reasonably well pick out enemy targets from their allies and dare risk to shoot. However, for each '1' rolled when rolling to Hit, a missile manages to go awry and hit the friendly unit instead. You are only allowed to fire into combat if the target is at Unit Strength 5 or more.
Some war machine weapons, particularly those that use templates, can accidentally hit friends whilst aiming at the enemy. The key word here is 'accidentally' – you cannot purposefully aim a template so that some of your models will be hit. Note that you may never target enemies engaged in close combat with templates, even if they are within 4".