Combat formation is set completely manually, it is you putting the mages in front and melee in back.

You choose the combat formation above your top character portrait. Default is a square.

The order your characters are in the lefthand portraits is the order they fill out the formation.

Move your mages portraits to below the melee characters portraits to have the melee characters in front of the mage characters.

Glad to have helped.