A. Use infantry
B.Stack 2 or more infantry squads on the same hex.
C.Never stay out in the open if you can help it.
D.Don't feel like you have to move every unit every turn.
E.Plan ambushes.
F.Back up your infantry with heavier equipment.
G.Finish off enemy squads if possible.
The best option is not to get involved in them, if you have to attack in these situations move slow & suppress them before you go. So if its due to being a dark night a walking barrage in front of you otherwise try & work units round to support at greater range or so you can attack the hex from several adj ones if its woods or such preferably with people behind to catch the runners.
Military commanders generally try & avoid confruntations in close quarters like urban for the simple reason they hurt.
Good scouting helps to so you have an idea what you are taking on.
If it's armour you are losing then you are trying to move way too fast they should not be in that close.
If its inf. you are still too close until you stun them some (retreat or rout status)
Stand back some, access the situation and always use smoke when things get too hot,as most inf. has it.