You are never required to shoot at the guy right next to you. The tank in question cannot shoot the mech that is B2B with him, but nothing stops him from ignoring that mech and shooting at someone else. Also, the vast majority of the time units do not interfere with line of sight, so nothing stops your tank from shooting through that mech to hit someone else.
(There are exceptions to this, but they're rare and usually require the use of a Special Pilot Ability.)
Also, welcome to the boards, and welcome to the game! :)